-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically create schemas for yaml config used by Hydra (#7)
* WIP: Automatically create yaml schemas for configs Signed-off-by: Fabrice Normandin <[email protected]> * Working (mostly)! Signed-off-by: Fabrice Normandin <[email protected]> * Add a .gitignore entry for schemas Signed-off-by: Fabrice Normandin <[email protected]> * Associate files to schemas via vscode settings Signed-off-by: Fabrice Normandin <[email protected]> * Improve descriptions Signed-off-by: Fabrice Normandin <[email protected]> * Update notes / todos Signed-off-by: Fabrice Normandin <[email protected]> * Fix doctest Signed-off-by: Fabrice Normandin <[email protected]> * Save progress so far (lots more to do :() Signed-off-by: Fabrice Normandin <[email protected]> * Ignore most hydra errors for now Signed-off-by: Fabrice Normandin <[email protected]> * Fix issues with logging verbosity Signed-off-by: Fabrice Normandin <[email protected]> * Rename functions and change signature Signed-off-by: Fabrice Normandin <[email protected]> * Make it possible to change only one file Signed-off-by: Fabrice Normandin <[email protected]> * Add "format on save" option to devcontainer Signed-off-by: Fabrice Normandin <[email protected]> * Fix bug in experiment/example.yaml Signed-off-by: Fabrice Normandin <[email protected]> * Format a yaml file Signed-off-by: Fabrice Normandin <[email protected]> * Regenerate schema if config changes Signed-off-by: Fabrice Normandin <[email protected]> * Remove unused imports in example.py Signed-off-by: Fabrice Normandin <[email protected]> * Add nice schema for `defaults` list! Signed-off-by: Fabrice Normandin <[email protected]> * Fix issue with unit test for auto schema Signed-off-by: Fabrice Normandin <[email protected]> * Add a 'features/auto_schema.md' file with a demo Signed-off-by: Fabrice Normandin <[email protected]> * Create schemas inside `main`, tweak defaults Signed-off-by: Fabrice Normandin <[email protected]> * Handle sub-entries with _target_ Signed-off-by: Fabrice Normandin <[email protected]> * Fix the errors in the test configs for auto_shema Signed-off-by: Fabrice Normandin <[email protected]> * Remove absolute path in regression files Signed-off-by: Fabrice Normandin <[email protected]> * Add tests to increase code coverage Signed-off-by: Fabrice Normandin <[email protected]> * Fix issue when writing yaml schema header Signed-off-by: Fabrice Normandin <[email protected]> * Add test to cover changes in `main.py` Signed-off-by: Fabrice Normandin <[email protected]> * "fix" type-checking errors in auto_schema.py Signed-off-by: Fabrice Normandin <[email protected]> --------- Signed-off-by: Fabrice Normandin <[email protected]>
- Loading branch information
Showing
57 changed files
with
2,196 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,3 +169,4 @@ lightning_logs | |
**.npz | ||
# .python-version | ||
.testmondata* | ||
.schemas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Auto Schema for Hydra Configs | ||
|
||
This project template comes with a really neat feature: Your [Hydra](https://hydra.cc) config files automatically get a [Schema](https://json-schema.org/) associated with them. | ||
|
||
This greatly improves the experience of developing a project with Hydra: | ||
|
||
- Saves you time by preventing errors caused by unexpected keys in your config files, or values that are of the wrong type | ||
This can often happen after moving files or renaming a function, for example. | ||
- While writing a config file you get to see: | ||
- the list of available configuration options in a given config | ||
- the default values for each value | ||
- the documentation for each value (taken from the source code of the function!) | ||
|
||
Here's a quick demo of what this looks like in practice: | ||
|
||
 | ||
|
||
Here we have a config that will be used to configure the `lightning.Trainer` class, but any config file in the project will also get a schema automatically, even if it doesn't have a `"_target_"` key directly! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
defaults: | ||
- mnist | ||
- mnist | ||
- _self_ | ||
_target_: project.datamodules.FashionMNISTDataModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
defaults: | ||
- vision | ||
- _self_ | ||
_target_: project.datamodules.ImageNetDataModule | ||
# todo: add good configuration options here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
defaults: | ||
- vision | ||
- vision | ||
- _self_ | ||
_target_: project.datamodules.INaturalistDataModule | ||
version: "2021_train" | ||
target_type: "full" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
_target_: lightning.Trainer | ||
|
||
logger: null | ||
accelerator: auto | ||
strategy: auto | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.