-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: allow config in command decorator #4
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #4 +/- ##
==========================================
+ Coverage 97.82% 97.86% +0.03%
==========================================
Files 8 8
Lines 644 655 +11
==========================================
+ Hits 630 641 +11
Misses 14 14
☔ View full report in Codecov by Sentry. |
c595e44
to
9d0f007
Compare
6c07215
to
08ac9fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great addition !
if initial_config is not None: | ||
initial_configs = ( | ||
[initial_config] | ||
if isinstance(initial_config, Config) | ||
else initial_config | ||
) | ||
|
||
initial_config_path = [] | ||
|
||
for c in initial_configs: | ||
temp_file = tempfile.NamedTemporaryFile(delete=False) | ||
temp_file.write( | ||
c.to_str().encode() | ||
) # Write the string to the file | ||
temp_file.close() | ||
initial_config_path.append(Path(temp_file.name)) | ||
config_path = initial_config_path + config_path | ||
|
||
if config_path: | ||
config, name_from_file = merge_from_disk(config_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel the disk writing operation is not really necessary, if its only purpose is to use merge_from_disk
. Could we drop merge_from_disk
, load all configs and merge them directly from memory instead ?
Description
The goal of this PR is to add an
config
argument in@app.command
. As such, it allows to pass one (or more)Config
object to the underlying script. All additional configurations provided through the CLI will still be used via merging.Then
python -m script.py
will run as isChecklist