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.

Facilitate configuration file loading outside training script

See original GitHub issue

🚀 Feature

I’d like to request a feature that would allow to use the LightningCLI configuration more easily in Jupyter notebooks, or in general, outside the main training script (e.g. for serving). This could be done by implementing a mode for LightningCLI that exposes the correctly configured parser without actually trying to parse any arguments.

Motivation

After training a model on the command line, I often want to load it in a Jupyter notebook, e.g. to run it on some toy examples. Often I need to create not just the model itself, but also the data module and maybe even the trainer, optimizers etc. Sometimes I even want to modify the configuration (e.g. the maximum sequence length in a Transformer) before creating the model.

With LightningCLI, this is not currently straightforward (see #10363, #12302).

Pitch

Probably the most flexible solution would be to implement a mode for LightningCLI that sets up and exposes the parser without actually trying to parse anything (e.g. parse=False). Then one could, for example, feed custom configuration (modified on the fly) via parser.parse_object(). Then one could call instantiate_classes(), ideally with the possibility to choose which top-level objects (model, data module, trainer) to instantiate.

cc @borda @carmocca @mauvilsa

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mauvilsacommented, Mar 21, 2022

@cifkao in the current version of jsonargparse in master there is now a way to capture the parser from a cli function. You can see the documentation for this feature at https://jsonargparse.readthedocs.io/en/latest/#capturing-parsers.

1reaction
mauvilsacommented, Mar 17, 2022

@mauvilsa I see… It’s probably possible to work around this, but in any case, it would be easier to have an option to skip all the parsing.

A workaround would not be advisable. I have thought a bit about this and right now I am not sure about a change in LightningCLI. I know of one more use case in which there is a need to get the parser of a CLI. Thus, it might make sense to add a feature to jsonargparse for this. Basically a way to capture the parser from a CLI without any need to modify the CLI.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Facilitate configuration file loading outside training script #12309
After training a model on the command line, I often want to load it in a Jupyter notebook, e.g. to run it on...
Read more >
Modularize Configuration Files | MuleSoft Documentation
Mule offers two options for loading multiple configuration files: Side-by-side: Provide a list of independent configuration files to load. Imported: Have one  ......
Read more >
Best Practices for Working with Configuration in Python ...
When you deal with configuration, there are various aspects to consider: First, how is it passed into your program from the outside, parsed, ......
Read more >
How do you deal with configuration files in source control?
Firstly reduce the number of configuration items you have in your main configuration file. · Split up the configuration file when possible, e.g....
Read more >
Chapter 1. Router Configuration and File Management - O'Reilly
The following set of commands allows you to automatically load a configuration file located on a remote TFTP server when the router boots:...
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