Skip to content

Commit

Permalink
Fix to use word DAG
Browse files Browse the repository at this point in the history
  • Loading branch information
yottahmd committed Apr 27, 2022
1 parent 9250f16 commit a2d9201
Show file tree
Hide file tree
Showing 32 changed files with 282 additions and 282 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Download the binary from [Releases page](https://github.com/dagu/dagu/releases)

- **History**: History of the execution of the pipeline.

![History](https://user-images.githubusercontent.com/1475839/165418472-385cb8e0-351c-4508-b337-a082ea53b4ec.png)
![History](https://user-images.githubusercontent.com/1475839/165426067-02c4f72f-e3f0-4cd8-aa38-35fa98f0382f.png)

## Architecture

Expand All @@ -120,7 +120,7 @@ Please create `~/.dagu/admin.yaml`.
```yaml
host: <hostname for web UI address> # default : 127.0.0.1
port: <port number for web UI address> # default : 8080
jobs: <the location of job configuration files> # default : current working directory
dags: <the location of DAG configuration files> # default : current working directory

# optional
command: <Absolute path of dagu binary if it's not in $PATH>
Expand All @@ -136,8 +136,8 @@ Please create `~/.dagu/config.yaml`. All settings can be overridden by individua
Creating a global configuration is a convenient way to organize common settings.

```yaml
logDir: <path-to-write-log> # log directory to write standard output from the job steps
histRetentionDays: 3 # job history retention days (not for log files)
logDir: <path-to-write-log> # log directory to write standard output
histRetentionDays: 3 # history retention days (not for log files)
# E-mail server config (optional)
smtp:
Expand Down
2 changes: 1 addition & 1 deletion cmd/jobctl.go → cmd/dagu.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func run() error {
func makeApp() *cli.App {
return &cli.App{
Name: "dagu",
Usage: "Simple command to run a group of jobs",
Usage: "A simple command to run workflows (DAGs)",
UsageText: "dagu [options] <start|status|stop|retry|dry|server> [args]",
Commands: []*cli.Command{
newStartCommand(),
Expand Down
4 changes: 2 additions & 2 deletions cmd/jobctl_test.go → cmd/dagu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func runAppTestOutput(app *cli.App, test appTest, t *testing.T) {
w.Close()

if err != nil && !test.errored {
t.Fatalf("job failed unexpectedly %v", err)
t.Fatalf("failed unexpectedly %v", err)
return
}

Expand All @@ -87,7 +87,7 @@ func runAppTest(app *cli.App, test appTest, t *testing.T) {
err := app.Run(test.args)

if err != nil && !test.errored {
t.Fatalf("job failed unexpectedly %v", err)
t.Fatalf("failed unexpectedly %v", err)
return
}
}
4 changes: 2 additions & 2 deletions cmd/dry.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func newDryCommand() *cli.Command {

func dryRun(cfg *config.Config) error {
a := &agent.Agent{Config: &agent.Config{
Job: cfg,
DAG: cfg,
Dry: true,
}}
listenSignals(func(sig os.Signal) {
Expand All @@ -51,7 +51,7 @@ func dryRun(cfg *config.Config) error {

err := a.Run()
if err != nil {
log.Printf("[DRY] job failed %v", err)
log.Printf("[DRY] failed %v", err)
}
return nil
}
8 changes: 4 additions & 4 deletions cmd/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ func newRetryCommand() *cli.Command {
if err != nil {
return err
}
return retryJob(cfg, status.Status)
return retry(cfg, status.Status)
},
}
}

func retryJob(cfg *config.Config, status *models.Status) error {
func retry(cfg *config.Config, status *models.Status) error {
a := &agent.Agent{
Config: &agent.Config{
Job: cfg,
DAG: cfg,
Dry: false,
},
RetryConfig: &agent.RetryConfig{
Expand All @@ -70,7 +70,7 @@ func retryJob(cfg *config.Config, status *models.Status) error {

err := a.Run()
if err != nil {
log.Printf("running job failed. %v", err)
log.Printf("running failed. %v", err)
}
return nil
}
16 changes: 8 additions & 8 deletions cmd/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ func Test_retryCommand(t *testing.T) {
output: []string{},
}, t)

job, err := controller.FromConfig(configPath)
dag, err := controller.FromConfig(configPath)
require.NoError(t, err)
require.Equal(t, job.Status.Status, scheduler.SchedulerStatus_Error)
require.Equal(t, dag.Status.Status, scheduler.SchedulerStatus_Error)

db := database.New(database.DefaultConfig())
status, err := db.FindByRequestId(configPath, job.Status.RequestId)
status, err := db.FindByRequestId(configPath, dag.Status.RequestId)
require.NoError(t, err)
dw, err := db.NewWriterFor(configPath, status.File)
require.NoError(t, err)
Expand All @@ -44,19 +44,19 @@ func Test_retryCommand(t *testing.T) {
app = makeApp()
runAppTestOutput(app, appTest{
args: []string{"", "retry", fmt.Sprintf("--req=%s",
job.Status.RequestId), testConfig("cmd_retry.yaml")}, errored: false,
dag.Status.RequestId), testConfig("cmd_retry.yaml")}, errored: false,
output: []string{"parameter is x"},
}, t)

assert.Eventually(t, func() bool {
job, err = controller.FromConfig(testConfig("cmd_retry.yaml"))
dag, err = controller.FromConfig(testConfig("cmd_retry.yaml"))
if err != nil {
return false
}
return job.Status.Status == scheduler.SchedulerStatus_Success
return dag.Status.Status == scheduler.SchedulerStatus_Success
}, time.Millisecond*3000, time.Millisecond*100)

job, err = controller.FromConfig(testConfig("cmd_retry.yaml"))
dag, err = controller.FromConfig(testConfig("cmd_retry.yaml"))
require.NoError(t, err)
require.NotEqual(t, status.Status.RequestId, job.Status.RequestId)
require.NotEqual(t, status.Status.RequestId, dag.Status.RequestId)
}
12 changes: 6 additions & 6 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ func newStartCommand() *cli.Command {
},
Action: func(c *cli.Context) error {
if c.NArg() == 0 {
return errors.New("config file must be specified.")
return errors.New("config file must be specified")
}
if c.NArg() != 1 {
return errors.New("too many parameters.")
return errors.New("too many parameters")
}
config_file_path := c.Args().Get(0)
cfg, err := cl.Load(config_file_path, c.String("params"))
if err != nil {
return err
}
return startJob(cfg)
return start(cfg)
},
}
}

func startJob(cfg *config.Config) error {
func start(cfg *config.Config) error {
a := &agent.Agent{Config: &agent.Config{
Job: cfg,
DAG: cfg,
Dry: false,
}}

Expand All @@ -52,7 +52,7 @@ func startJob(cfg *config.Config) error {

err := a.Run()
if err != nil {
log.Printf("running job failed. %v", err)
log.Printf("running failed. %v", err)
}
return nil
}
8 changes: 4 additions & 4 deletions cmd/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ func newStopCommand() *cli.Command {
if err != nil {
return err
}
return stopJob(cfg)
return stop(cfg)
},
}
}

func stopJob(cfg *config.Config) error {
func stop(cfg *config.Config) error {
status, err := controller.New(cfg).GetStatus()
if err != nil {
return err
}

if status.Status != scheduler.SchedulerStatus_Running ||
!status.Pid.IsRunning() {
log.Printf("job is not running.")
log.Printf("DAG is not running.")
return nil
}
syscall.Kill(int(status.Pid), syscall.SIGINT)
Expand All @@ -55,6 +55,6 @@ func stopJob(cfg *config.Config) error {
}
break
}
log.Printf("job is stopped.")
log.Printf("DAG is stopped.")
return nil
}
File renamed without changes.
3 changes: 3 additions & 0 deletions examples/config_err_step_no_command.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: test
steps:
- name: step 1
2 changes: 1 addition & 1 deletion examples/example_1.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: example job
name: example DAG
steps:
- name: "1"
command: echo hello world
Expand Down
12 changes: 6 additions & 6 deletions internal/admin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Config struct {
Host string
Port string
Env []string
Jobs string
DAGs string
Command string
WorkDir string
IsBasicAuth bool
Expand All @@ -41,12 +41,12 @@ func (c *Config) setup() error {
if c.Command == "" {
c.Command = "dagu"
}
if c.Jobs == "" {
if c.DAGs == "" {
wd, err := os.Getwd()
if err != nil {
return err
}
c.Jobs = wd
c.DAGs = wd
}
if c.Host == "" {
c.Host = "127.0.0.1"
Expand Down Expand Up @@ -81,14 +81,14 @@ func buildFromDefinition(def *configDefinition) (c *Config, err error) {
}
c.Port = strconv.Itoa(def.Port)

jd, err := parseVariable(def.Jobs)
jd, err := parseVariable(def.Dags)
if err != nil {
return nil, err
}
if !filepath.IsAbs(jd) {
return nil, fmt.Errorf("jobs directory should be absolute path. was %s", jd)
return nil, fmt.Errorf("DAGs directory should be absolute path. was %s", jd)
}
c.Jobs, err = filepath.Abs(jd)
c.DAGs, err = filepath.Abs(jd)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/admin/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type configDefinition struct {
Host string
Port int
Env map[string]string
Jobs string
Dags string
Command string
WorkDir string
IsBasicAuth bool
Expand Down
Loading

0 comments on commit a2d9201

Please sign in to comment.