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

Add support for overriding inputs via CLI args #31

Merged
merged 5 commits into from
Mar 1, 2021
Merged

Add support for overriding inputs via CLI args #31

merged 5 commits into from
Mar 1, 2021

Conversation

JuhaKiili
Copy link
Contributor

You can locally override only the parameters through the CLI currently. For example:

python train.py --lr=0.001

In Valohai CLI & UI you can also override inputs. We need to have that from valohai-utils too. For example:

python train.py --images=/tmp/lol/*.png

This PR makes that possible.

@JuhaKiili JuhaKiili requested a review from akx February 19, 2021 10:25
valohai/utils.py Outdated
if "://" not in value and os.path.isfile(value): # The string is a local path
files.append(FileInfo(name=os.path.basename(value), uri=None, path=value, size=None, checksums=None))
else: # The string is an URI
files.append(FileInfo(name=FileInfo.uri_to_filename(value), uri=value, path=None, size=None, checksums=None))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the reason uri_to_filename feels like it should be a free function...

valohai/utils.py Outdated
Comment on lines 52 to 53
inputs = {k: v for k, v in vars(args).items() if k in names}
for name, values in inputs.items():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe simpler put as

Suggested change
inputs = {k: v for k, v in vars(args).items() if k in names}
for name, values in inputs.items():
for name, values in vars(args).items():
if name not in names:
continue

valohai/utils.py Outdated
Comment on lines 78 to 79
parameters = {k: v for k, v in vars(args).items() if k in names}
for name, value in parameters.items():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
parameters = {k: v for k, v in vars(args).items() if k in names}
for name, value in parameters.items():
for name, value in vars(args).items():
if name not in names:
continue

@JuhaKiili JuhaKiili requested a review from akx February 26, 2021 09:03
@akx akx merged commit 99b83f1 into master Mar 1, 2021
@akx akx deleted the cli-inputs branch March 1, 2021 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants