I wrote a helpful github gist

I wanted to debug or do some quick runs on my project without logging the results, but I had set everything up to work with guild. Since all my params/config was in the guild.yml file I thought I could repurpose it to just run from the command line.

I wrote up my own solution and have been using it and found it to be very helpful (it also helps to use it in notebooks, etc to load the params for quick experimentation), so I put it into a gist.

I hope it helps!

1 Like

Nice - very clean!

I wonder if Guild could support this with an option. From what I gather, you want to make sure the following holds:

  • A run is not created.
  • Your code runs from its project location (no copies) and from the same directory you run the command from.
  • Guild doesn’t write anything including metadata, logs, scalars, etc.
  • Guild does not attempt to resolve dependencies.

This basically would provide the flags interface to running your project code in place.

Though in thinking about this, I wonder perhaps if that’s the wrong direction. Guild should not really be a requirement for running your code in-place like that. Ideally you can just delete Guild and your project is perfectly fine.

In the case of command line args, which is what you’re using, the intent is that you’d define your default values in your scripts — e.g. p.add_argument("--foo", default=1.123, type=float). You can always just run the script directly and it gets the values as expected. When Guild run, it looks at your code and imports the values.

Does this arrangement not work in your case?

Guild isn’t quite a requirement, but I have so many different configurations that I’ve built around the guild.yml file that I just was repurposing the file for changing my params on the fly for quick runs.

For example, If I change the dataset I’m using, then the parameters I have to pass changes for my script. I have all these config objects already created in my guild file, I was hijacking them to make my life easier. Now I don’t have to say I need x, y, z, g, f, h variables. I can just grab whatever exists in the guild file and my script will only take what it needs for the particular dataset for example.

Ah I see, that makes sense.

What you have there is great so don’t worry about this too much, but if you want to use the Guild API for loading projects it looks like this:

>>> from guild import guildfile
>>> gf = guildfile.for_dir(".")
>>> gf.models
{'': <guild.guildfile.ModelDef ''>}
>>> gf.default_model
<guild.guildfile.ModelDef ''>
>>> gf.default_model.operations
[<guild.guildfile.OpDef 'hello'>,
 <guild.guildfile.OpDef 'hello-file'>,
 <guild.guildfile.OpDef 'hello-op'>]
>>> gf.default_model.get_operation("hello")
<guild.guildfile.OpDef 'hello'>
>>> gf.default_model.get_operation("hello").flag_values()
{'msg': 'Hello Guild!'}

Using the guildfile module will give you support for a number of implicit coersions, imports, and includes that might not be worth addressing in your code. That said, if what you have works, stick with it!

Thanks for the contribution!

1 Like