CHIMEFRB / workflow

🌊 Working in flowstate.
0 stars 0 forks source link

119 fix lifecycle/configure.py's defaults/arguments functions, does not work for @click.argument types #127

Closed chrisfandrade16 closed 1 month ago

chrisfandrade16 commented 1 month ago

Since we are using the .main method to call a Click command (as opposed to .callback which skips the Click CLI), all defaults are already calculated. As such, we don't even need to use configure.defaults. Instead, I modified configure.arguments to correctly build the Click CLI command for the .main method usage, such that the Click CLI is used and all defaults, type conversions, and constraints and performed automatically by Click. This new modified configure.arguments function accounts for both @click.argument and @click.option types, as well as is_flag=True types.

odarotto commented 1 month ago

@chrisfandrade16 LGMT, I think this would fix https://github.com/CHIMEFRB/workflow/issues/97, have you tested the case were the Work object is retried and keeps the same parameters?

chrisfandrade16 commented 1 month ago

@odarotto Good idea, I have not tried that...any ideas on how to test that? A function that fails the first time but works the second? Perhaps I can think of something.

chrisfandrade16 commented 1 month ago

@odarotto Just tested it. Ran a function that fails the first time (checks for a file, if does not exist, fails but creates it so the next time it succeeds), with work.retries = 2. Tried it with both @click.argument and @click.option and is_flag=True, all the parameters were still there the second time. Honestly, I'm not sure what I did to fix that issue though haha. I don't know what configure.defaults was doing in the first place to cause that.