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

Is there a way to unfreeze a frozen instance? #21

Open
volkerjaenisch opened this issue Oct 14, 2021 · 7 comments
Open

Is there a way to unfreeze a frozen instance? #21

volkerjaenisch opened this issue Oct 14, 2021 · 7 comments

Comments

@volkerjaenisch
Copy link

Dear @diegojromerolopez

Thank you for this nice piece of software!
I need a frozen instance that I later can make a unfrozen (deep-)copy of. This is used for IMHO typical (scientific) data processing chains:

  1. Calculate a instance of an intermediate result A and store it frozen (e.g. load a dataset)
  2. Calculate a result B that depend on A but shares the same metadata (e.g. b = filter(A), or B= smooth(A))
  3. Store B frozen
    ...

In your documentation you stated that (deep-)copy of a frozen instance is not possible.

So I see two ways to achieve this goal:

  1. There may be a way to unfreeze a frozen instance?
  2. There may be a way to access the original instance below the frozen structural sharing?

Any help appreciated

Cheers,
Volker

@diegojromerolopez
Copy link
Owner

Hello volkerjaenisch

Glad you find this project interesting and useful!

At the moment there is no way to unfreeze an instance, nor a way to get the original instance. I suppose you could have a side-effect in the on_freeze function, but that's not an elegant solution at all.

However, it's an interesting feature so I'm going to take a look and see if I can have a solution for this in a couple of days.

Best regards.

@volkerjaenisch
Copy link
Author

Hello @diegojromerolopez
Thank you very much for the fast response. I would be really happy if a solution could be found.
I am staying tuned.
Volker

@diegojromerolopez
Copy link
Owner

@volkerjaenisch I have a possible solution for your problem in this PR: #22 please, check it out and see if it suits your needs.

Otherwise, could you give me a mock example of the pipeline you're trying to implement (for example using a toy dataset)? That way I could have a more clear idea of your use-case.

@volkerjaenisch
Copy link
Author

@diegojromerolopez
Perfect!
I will checkout your code tomorrow
Volker

@diegojromerolopez
Copy link
Owner

Nice, keep me posted!

@volkerjaenisch
Copy link
Author

@diegojromerolopez
It seems to work.

But I learned that your code does not work inplace (build a readonly wrapper around the given instance) but returns a copy which is then made readonly. Sorry for not having understood that before I asked you. Since in that case of a not inplace operation we could use the original version of gelidum.

Also I noticed that you code does not support numpy arrays which I will open a separate issue for.

Sorry for the not so positive feedback. I really appreciate your effort

Volker

@diegojromerolopez
Copy link
Owner

Exactly, the code of the PR does not work in-place, because now I have not a clear idea of how to unfreeze a frozen object. I'll need to think about this.

This package has some limitations, like not supporting classes with __slots__, maybe numpy arrays have that or for other reason gelidum does not support them.

No worries, any constructive feedback is positive feedback. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants