Rename "debug" to "development"

This commit is contained in:
Lennart Kats 2023-07-03 16:30:42 +02:00
parent 458a2d0b1a
commit 4762716f73
7 changed files with 24 additions and 26 deletions

View File

@ -2,12 +2,6 @@ package config
type Mode string
const (
Debug Mode = "debug"
Default Mode = "default"
PullRequest Mode = "pull-request"
)
// Environment defines overrides for a single environment.
// This structure is recursively merged into the root configuration.
type Environment struct {
@ -30,3 +24,9 @@ type Environment struct {
// in the scope of an environment
Variables map[string]string `json:"variables,omitempty"`
}
const (
// Right now, we just have a default / "" mode and a "development" mode.
// Additional modes are expected to come for pull-requests and production.
Development Mode = "development"
)

View File

@ -37,7 +37,7 @@ func (m *overrideCompute) Apply(ctx context.Context, b *bundle.Bundle) error {
if m.compute == "" {
return nil
}
if b.Config.Bundle.Mode != config.Debug {
if b.Config.Bundle.Mode != config.Development {
return fmt.Errorf("cannot override compute for an environment that does not use 'mode: debug'")
}

View File

@ -18,7 +18,7 @@ func TestOverrideCompute(t *testing.T) {
bundle := &bundle.Bundle{
Config: config.Root{
Bundle: config.Bundle{
Mode: config.Debug,
Mode: config.Development,
},
Resources: config.Resources{
Jobs: map[string]*resources.Job{

View File

@ -21,18 +21,18 @@ func (m *processEnvironmentMode) Name() string {
return "ProcessEnvironmentMode"
}
// Mark all resources as being for 'debug' purposes, i.e.
// Mark all resources as being for 'development' purposes, i.e.
// changing their their name, adding tags, and (in the future)
// marking them as 'hidden' in the UI.
func processDebugMode(b *bundle.Bundle) error {
func processDevelopmentMode(b *bundle.Bundle) error {
r := b.Config.Resources
for i := range r.Jobs {
r.Jobs[i].Name = "[debug] " + r.Jobs[i].Name
r.Jobs[i].Name = "[dev] " + r.Jobs[i].Name
if r.Jobs[i].Tags == nil {
r.Jobs[i].Tags = make(map[string]string)
}
r.Jobs[i].Tags["debug"] = ""
r.Jobs[i].Tags["dev"] = ""
if r.Jobs[i].MaxConcurrentRuns == 0 {
r.Jobs[i].MaxConcurrentRuns = debugConcurrentRuns
}
@ -48,19 +48,19 @@ func processDebugMode(b *bundle.Bundle) error {
}
for i := range r.Pipelines {
r.Pipelines[i].Name = "[debug] " + r.Pipelines[i].Name
r.Pipelines[i].Name = "[dev] " + r.Pipelines[i].Name
r.Pipelines[i].Development = true
// (pipelines don't yet support tags)
}
for i := range r.Models {
r.Models[i].Name = "[debug] " + r.Models[i].Name
r.Models[i].Tags = append(r.Models[i].Tags, ml.ModelTag{Key: "debug", Value: ""})
r.Models[i].Name = "[dev] " + r.Models[i].Name
r.Models[i].Tags = append(r.Models[i].Tags, ml.ModelTag{Key: "dev", Value: ""})
}
for i := range r.Experiments {
r.Experiments[i].Name = "[debug] " + r.Experiments[i].Name
r.Experiments[i].Tags = append(r.Experiments[i].Tags, ml.ExperimentTag{Key: "debug", Value: ""})
r.Experiments[i].Name = "[dev] " + r.Experiments[i].Name
r.Experiments[i].Tags = append(r.Experiments[i].Tags, ml.ExperimentTag{Key: "dev", Value: ""})
}
return nil
@ -68,12 +68,10 @@ func processDebugMode(b *bundle.Bundle) error {
func (m *processEnvironmentMode) Apply(ctx context.Context, b *bundle.Bundle) error {
switch b.Config.Bundle.Mode {
case config.Debug:
return processDebugMode(b)
case config.Default, "":
case config.Development:
return processDevelopmentMode(b)
case "":
// No action
case config.PullRequest:
return fmt.Errorf("not implemented")
default:
return fmt.Errorf("unsupported value specified for 'mode': %s", b.Config.Bundle.Mode)
}

View File

@ -19,7 +19,7 @@ func TestProcessEnvironmentModeApplyDebug(t *testing.T) {
bundle := &bundle.Bundle{
Config: config.Root{
Bundle: config.Bundle{
Mode: config.Debug,
Mode: config.Development,
},
Resources: config.Resources{
Jobs: map[string]*resources.Job{

View File

@ -159,7 +159,7 @@ func TestRootMergeEnvironmentWithMode(t *testing.T) {
root := &Root{
Bundle: Bundle{},
}
env := &Environment{Mode: Debug}
env := &Environment{Mode: Development}
require.NoError(t, root.MergeEnvironment(env))
assert.Equal(t, Debug, root.Bundle.Mode)
assert.Equal(t, Development, root.Bundle.Mode)
}

View File

@ -16,7 +16,7 @@ func TestJobAndPipelineDevelopment(t *testing.T) {
p := b.Config.Resources.Pipelines["nyc_taxi_pipeline"]
assert.Equal(t, "job_and_pipeline/bundle.yml", filepath.ToSlash(p.ConfigFilePath))
assert.Equal(t, b.Config.Bundle.Mode, config.Debug)
assert.Equal(t, b.Config.Bundle.Mode, config.Development)
assert.True(t, p.Development)
require.Len(t, p.Libraries, 1)
assert.Equal(t, "./dlt/nyc_taxi_loader", p.Libraries[0].Notebook.Path)