Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Attempting to save a model without specifying a path throws an exception on Windows #1560

Closed
JLC827 opened this issue Feb 11, 2023 · 2 comments · Fixed by #1501
Closed
Assignees
Labels
bug Something isn't working

Comments

@JLC827
Copy link

JLC827 commented Feb 11, 2023

Describe the bug
The model documentation states that when calling model.save the path parameter is optional, and that "If no path is specified, the model is automatically saved under "{ModelClass}_{YYYY-mm-dd_HH:MM:SS}.pt". E.g., "RNNModel_2020-01-01_12:00:00.pt".

However, if it is left unfilled the following exception will be thrown:

File "...\venv\lib\site-packages\darts\models\forecasting\torch_forecasting_model.py", line 1271, in save
    with open(path, "wb") as f_out:
OSError: [Errno 22] Invalid argument: 'RNNModel_2023-02-11_23:31:42.pt'

I assume this is because ':' cannot be used in file names in Windows. One possibility is to use the formatting of '%Y%m%d-%H%M%S' as specified in this Stack Overflow post.

To Reproduce
Simply run.

from darts.models import RNNModel

model = RNNModel(input_chunk_length=4)
model.save()

Expected behavior
It is expected for the model to save in the current working dir in a reasonable model name and date format.

System (please complete the following information):

  • Python version: 3.10
  • darts version 0.23.1
  • Windows 10.0.19045

Thanks!

@JLC827 JLC827 added bug Something isn't working triage Issue waiting for triaging labels Feb 11, 2023
@madtoinou madtoinou removed the triage Issue waiting for triaging label Feb 13, 2023
@madtoinou madtoinou self-assigned this Feb 14, 2023
@madtoinou madtoinou linked a pull request Feb 14, 2023 that will close this issue
@madtoinou
Copy link
Collaborator

Hi,

I added a fix in PR #1501 (":" was replaced with "_"), it should be part of next darts release.

@JLC827
Copy link
Author

JLC827 commented Feb 15, 2023

Excellent, thank you @madtoinou!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants