question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

request for alternative argparse format in sweep

See original GitHub issue

wandb --version && python --version && uname

  • Weights and Biases version: wandb, version 0.8.36
  • Python version: Python 3.8.2
  • Operating System: Darwin

Description

Sweep config file will format the hyperparams into the form of --foo=bar doc here and code responsible.

When using with Facebook’s config library Hydra, this becomes an issue as no argparse is allowed, i.e. no --foo=bar (see here). For instance, when wandb agent runs a command: python train.py --lr=0.02 this breaks the code that uses it; instead it needs the command to be python train.py lr=0.02, then Hydra will pick it up.

Is it possible to allow for usage without the prefix --? This would enable very nice pairing with Hydra to manage complex configurations while still allowing sweep to work. Plus, Hydra is getting quite popular and is used with Ax and PyTorch Lightning.

Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
vanpeltcommented, May 21, 2020

Hey @kengz you can customize how your program is called and optionally omitting arguments. In this examples args is still prepended with “–”, we should expose the ability to change the prefix in this config so I’ll keep this ticket open. In the meantime you can have the sweep execute a wrapper script that modifies the parameters before calling your script:

import sys
import os

args = sys.argv[1:]
bare = [a.replace("--", "") for a in args]
os.system(f"python train.py {' '.join(bare)}")
0reactions
raubitsjcommented, Nov 6, 2020

@varun19299 , I am closing this issue, we do have some plans to integrate with other sweep tools in the future. If you want to make a new feature request we can track your request.

Read more comments on GitHub >

github_iconTop Results From Across the Web

request for alternative argparse format in sweep #1052 - GitHub
When using with Facebook's config library Hydra, this becomes an issue as no argparse is allowed, i.e. no --foo=bar (see here).
Read more >
argparse — Parser for command-line options, arguments and ...
ArgumentParser objects allow the help formatting to be customized by specifying an alternate formatting class. Currently, there are four such classes:.
Read more >
Getting started | Hydra
This guide will show you some of the most important features you get by writing your application as a Hydra app. If you...
Read more >
Python algorithm mimicking mark/sweep garbage collection 2.0
In this answer I'm going to discuss the general design of the garbage collection algorithm. Of course what you have here is just...
Read more >
Customize argparse help message - python - Stack Overflow
Something like parser.usage = edit(parser.format_help()) , then just write a function edit to parse each line converting the help string to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found