Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot parse named params #563

Open
anishjain94 opened this issue May 8, 2024 · 8 comments
Open

Cannot parse named params #563

anishjain94 opened this issue May 8, 2024 · 8 comments

Comments

@anishjain94
Copy link

anishjain94 commented May 8, 2024

I am not able to add named params. It gives the following error. Attaching workflow config file for referece. what am i doing wrong here. can somebody help me please.

description: invoice_generation
schedule: '0 3 4 * *'
group: user
tags: user

histRetentionDays: 1
maxActiveRuns: 1
delaySec: 1
MaxCleanUpTimeSec: 5000
logDir: /home/dagu/logs/dags
params: "invoice_date=2024-05-05"

steps:
  - name: INVOICE_NUMBER_GENERATION
    description: Invoice number generation
    command: /home/dagu/bin/cron INVOICE_NUMBER_GENERATION ${invoice_date}
    signalOnStop: 'SIGINT'
  - name: INVOICE_DATA_POPULATION
    description: Invoice data population
    command: /home/dagu/bin/cron INVOICE_DATA_POPULATION ${invoice_date}
    signalOnStop: 'SIGINT'
    depends:
      - INVOICE_NUMBER_GENERATION
  - name: INVOICE_IRN_GENERATION
    description: Invoice IRN generation
    command: /home/dagu/bin/cron INVOICE_IRN_GENERATION ${invoice_date}
    signalOnStop: 'SIGINT'
    depends:
      - INVOICE_DATA_POPULATION
Screenshot 2024-05-08 at 16 25 47
@yohamta
Copy link
Collaborator

yohamta commented May 8, 2024

Hello,

I just have tried it and it seems working fine on my environment with the configuration:

description: invoice_generation
schedule: '0 3 4 * *'
group: user
tags: user

histRetentionDays: 1
maxActiveRuns: 1
delaySec: 1
MaxCleanUpTimeSec: 5000
params: "invoice_date=2024-05-05"

steps:
  - name: INVOICE_NUMBER_GENERATION
    description: Invoice number generation
    command: echo ${invoice_date}
    signalOnStop: 'SIGINT'
  - name: INVOICE_DATA_POPULATION
    description: Invoice data population
    command: echo ${invoice_date}
    signalOnStop: 'SIGINT'
    depends:
      - INVOICE_NUMBER_GENERATION
  - name: INVOICE_IRN_GENERATION
    description: Invoice IRN generation
    command: echo ${invoice_date}
    signalOnStop: 'SIGINT'
    depends:
      - INVOICE_DATA_POPULATION
image

@anishjain94
Copy link
Author

Yes. It was my fault. i was using this in docker environment and did not remove volume. that was causing the issue. could you tell me how to use named params in code. i tried printing os.Args when using named parameters, but no additional argument was present.

@yohamta
Copy link
Collaborator

yohamta commented May 8, 2024

I understand. Named parameters are passed as environment value to each step, so you can get the value via os.Getenv() for example.

@anishjain94
Copy link
Author

This helps. thank you so much. Closing this issue now. Again thank you for your effort.

@anishjain94
Copy link
Author

Hi, also just one more thing. when passing named params, i am able to access named params from os.Getenv() but it turns out that it overrides or removes my existing envs when called using a func.

description: Test DAG
schedule: '* * * * *'
group: Test
tags: Test
params: invoice_date=2012-01-01
histRetentionDays: 1
maxActiveRuns: 1
delaySec: 1
MaxCleanUpTimeSec: 5000
logDir: /home/dagu/logs/dags

steps:
  - name: test
    description: test
    signalOnStop: SIGINT
    command: /home/dagu/bin/cron TEST ${invoice_date}
func main() {
	fmt.Println(os.ExpandEnv("$GOPATH"))
	fmt.Println("Args", os.Args)
	fmt.Println("Env", os.Getenv("invoice_date"))

	err := godotenv.Load(os.ExpandEnv("$GOPATH/src/pice_core/config/default.env"))
	util.AssertError(err, util.INIT_ERROR, http.StatusInternalServerError, "unable to load default.env file")

}

The first line here is my GOPATH variable which is not present.
Screenshot 2024-05-09 at 12 58 31

@anishjain94 anishjain94 reopened this May 9, 2024
@yohamta
Copy link
Collaborator

yohamta commented May 9, 2024

Hi @anishjain94 ,
Currently Dagu doesn't inherit environment variables other than PATH, so you will need to define those variables explicitly in ~/dagu/config.yaml or in each DAG.

We're thinking to change this behavior in the future release.

@anishjain94
Copy link
Author

Ok got it. But when i am using named params only then this issue is caused. when i use normal params, i do not get this issue. why is that?

@yohamta
Copy link
Collaborator

yohamta commented May 9, 2024

I understand there's an issue. Let's fix this.
I believe it's the same issue to:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants