changed model path to shared dir path#1799
Conversation
| path = get_path_model(run_id=run_id) | ||
| else: | ||
| path = Path(model_path) / run_id | ||
| path = _get_shared_wg_path() / "models" / run_id |
There was a problem hiding this comment.
There is already a method for this.
I think we shouldn't change this. It is used when an explicit model_path was given. Otherwise the if-else block is redundant and we can just use the part in the if-block.
There was a problem hiding this comment.
Indeed the else is redundant, I will revert and add a logging instead
| """ | ||
|
|
||
| path_run = Path(cf.model_path) / run_id | ||
| path_run = _get_shared_wg_path() / "models" / run_id |
There was a problem hiding this comment.
Same applies here. We could use this method directly. Maybe we can add the same if-else block as in the previous case. This enables the user to not add a model_path to the config and just use the regular path. But I'm not entirely sure if this is possible here. Maybe someone with more experience on the model and training process knows better. @sophie-xhonneux ?
|
Thank you @TillHae for taking the time to review this PR, I added the requested changes ^^ |
| mini_epoch : The mini_epoch to load. Default (-1) is the latest mini_epoch | ||
| """ | ||
|
|
||
| path_run = Path(cf.model_path) / run_id |
There was a problem hiding this comment.
Let's use the same if-else block from config.py. If the user enters a model_path we should use it instead of creating it from the run_id.
There was a problem hiding this comment.
If there's shared code that needs to be identical in two places, can we please write a function that ensures it's indeed identical.
There was a problem hiding this comment.
Let's use the same if-else block from
config.py. If the user enters amodel_pathwe should use it instead of creating it from therun_id.
Hi @TillHae, I changed it to https://github.com/ecmwf/WeatherGenerator/pull/1799/changes#diff-2e85cd26b59453d8cbf3b54ed76e4cf092f911b8063dde53addf8ea81f0ca28dR183
Please let me know if this is what you meant or not.
There was a problem hiding this comment.
@sbAsma this is exactly what I meant. I think this should also fix the error from #1790. But I still have three small suggestions.
- define a method for this in
config.py, which we can then use in both places as @clessig requested. In that case we also don't need theget_model_pathimport anymore. - remove the additional variable
user_defined_pathand just usepath_runas inconfig.py - Remove the space before
.exists()in l. 185
There was a problem hiding this comment.
I moved the routine to config.py and re-used the method get_model_path(). Lemme know if this works.
| mini_epoch : The mini_epoch to load. Default (-1) is the latest mini_epoch | ||
| """ | ||
|
|
||
| path_run = Path(cf.model_path) / run_id |
There was a problem hiding this comment.
@sbAsma this is exactly what I meant. I think this should also fix the error from #1790. But I still have three small suggestions.
- define a method for this in
config.py, which we can then use in both places as @clessig requested. In that case we also don't need theget_model_pathimport anymore. - remove the additional variable
user_defined_pathand just usepath_runas inconfig.py - Remove the space before
.exists()in l. 185
| def get_path_model(config: Config | None = None, run_id: str | None = None) -> Path: | ||
| """Get the current runs model_path for storing model checkpoints.""" | ||
| if config or run_id: | ||
| run_id = run_id if run_id else get_run_id_from_config(config) |
There was a problem hiding this comment.
Can you take a look on this. Maybe this is already everything we need.
| path_run = Path(cf.model_path) / run_id | ||
| # If `run_id` is a full filesystem path to a model run directory, use it | ||
| # directly. This matches the behaviour of `config.load_run_config`, which | ||
| # accepts full-path run_id values. |
There was a problem hiding this comment.
It looks like this is no longer true. get_path_model doesn't handle the case of run_id being a full filesystem path.
There was a problem hiding this comment.
as far as I know, and correct me if I am wrong, run_id isn't supposed to be a full system path. @grassesi What do you think?
There was a problem hiding this comment.
If I remember correctly, for some time in the beginning there was a wish that one can load a model directly by specifying a path. Since our infrastructure has matured quite a bit since then, I feel like it is not required anymore, but I dont know if this option is still in use. @clessig do you know if this is still actively used? can we go ahead and remove this?
There was a problem hiding this comment.
Still good to have, especially with git worktrees or when setting up people during a hackathon or locally. Please don't remove.
There was a problem hiding this comment.
I don't think it should be possible that run_id is a model path. The better solution is that we allow for model_path, result_path (and potential slurm_path) to be overwritten in the CLI.
| # If a user provided `model_path` in the config, prefer it when the | ||
| # directory for the requested run exists. Otherwise fall back to the | ||
| # shared models directory. | ||
| if config is not None: |
There was a problem hiding this comment.
I think adding this to get_path_model is the wrong idea. We should create an entirely new method, which uses get_path_model. Then we can apply it to config.py ll. 232-237 and model_interface.py l. 184, because that is the actual same code that we have.
Description
Issue Number
Closes #1790
Is this PR a draft? Mark it as draft.
Checklist before asking for review
./scripts/actions.sh lint./scripts/actions.sh unit-test./scripts/actions.sh integration-testlaunch-slurm.py --time 60