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

Can't deepcopy or load a NeuralProphet instance (combination of save & load methods throws an exception) #1200

Closed
1 task done
almostintuitive opened this issue Mar 7, 2023 · 4 comments
Labels
priority:P1 High priority type:bug Something isn't working

Comments

@almostintuitive
Copy link

almostintuitive commented Mar 7, 2023

Prerequisites

Describe the bug

deepcopy() throws an exception, a manual implementation also fails with the following error message:
AttributeError: 'NeuralProphet' object has no attribute 'early_stopping'

To Reproduce

Steps to reproduce the behavior:

  1. Either call deepcopy() on a fitted model, results in RuntimeError: Only Tensors created explicitly by the user (graph leaves) support the deepcopy protocol at the moment

OR

  1. Run the following code:
from io import BytesIO
from neuralprophet.utils import load, save
buff = BytesIO()
save(self.model, buff)
buff.seek(0)
model = load(buff)

Results in : AttributeError: 'NeuralProphet' object has no attribute 'early_stopping'

Expected behavior

Able to deepcopy a NeuralProphet instance, one way or another.

What actually happens

When deepcopy is called, we get an exception:
RuntimeError: Only Tensors created explicitly by the user (graph leaves) support the deepcopy protocol at the moment

When we save & load the object, we get the exception:
AttributeError: 'NeuralProphet' object has no attribute 'early_stopping'

Screenshots

If applicable, add screenshots and console printouts to help explain your problem.

Environement (please complete the following information):

Python 3.9.15, in standalone venv with no other packages
NeuralProphet 0.5.2, installed from PYPI with pip install neuralprophet

Additional context

We want to integrate NeuralProphet into our time series cross-validation library called fold. We have written a wrapper that fails during a mandatory call to deepcopy() that we have to enable paralellism and safety.
dream-faster/fold-models#17

A github Action log failing with one of the exceptions can be found here:
https://github.com/dream-faster/fold-models/actions/runs/4356218584/jobs/7613915633

@leoniewgnr
Copy link
Collaborator

Hi @almostintuitive, thanks for reporting this!
Are you currently working yourself on this or do you need our help?
Because we are planning to close all open issues soon, so just want to check in what's the status on this.
Let me know if you need help:)

@leoniewgnr
Copy link
Collaborator

@almostintuitive isn't this tested by the pytest def test_save_load() in https://github.com/ourownstory/neural_prophet/blob/main/tests/test_utils.py?

@leoniewgnr
Copy link
Collaborator

closed due to inactivity

@almostintuitive
Copy link
Author

@leoniewgnr I believe this is happening when we're trying to deepcopy OR save/load an unfitted model, before fitting begins. we do this so we don't end up mutating a shared object (between threads, for example).
would it be useful if I contributed a (failing) unit test demonstrating this?

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

No branches or pull requests

4 participants