-
Notifications
You must be signed in to change notification settings - Fork 50
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
Fix Component Modeler Batch Path #1259
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but I'm a little puzzled why doesn't Tidy3DBaseModel.__hash__
work? Do you understand what makes it change in when starting a new session?
There's a random seed that gets set each session for python's built in |
So does this mean that more generally our simulations don't have the same hash across sessions? This would be a problem with simulation caching right? |
Yea (just verified). We'll just have to make sure to use a different hash function than the builtin python one I guess. |
I think one (easier to implement?) option is Yannick's suggestion in #1262 . In that sense do you want to implement this here already? It feels like maybe such a Also, how do we do hash for base models currently? If the new function won't be slower, then we may even completely replace the default hash? |
There are two suggestions, one of them involves hashing
You mean just move this to base model? I guess that works. I am hesitant to change the default hash until we are working more seriously on the simulation cache.
We use I can change the PR to reflect this discussion if you agree:
|
Just to clarify, this PR is to fix a pretty specific issue where the |
I agree with @tylerflex in leaving the default For the issue at hand, I think it's important to include the full contents of the object for hashing in component modeler, because we don't verify that the file actually represents the desired model (by verifying equality of the whole contents). I can imagine using component models to store different devices that only differ in their custom medium (maybe steps in an optimization or sweep run) only to find out their files have been overwritten one after the other. It will be less likely to happen (but not impossible) with a full hash. More generally, the hash only exists to assert difference, not identity, so I think that's how we should be using it later for serious caching. |
Ok, yeah, I thought we had already manually overwritten the default hash, but if we haven't, then let's not change that. I think at some point we were manually using the json but that was porbably because for some reason default wasn't working. Yeah, I was referring to the second approach proposed by Yannick, or at least some way like that for us to introduce a hash that is a) unique as long as the component (including custom data) is unique b) persistent among python sessions. Using the dict should also be fine I think? And yeah this is indeed what I'm suggesting for this PR:
|
0228efe
to
07e81cc
Compare
…er._batch_file' inconsistency.
07e81cc
to
55848da
Compare
Ok made the changes discussed
please take another look and let me know if there are any comments or merge it if it looks good, thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Better to have it in the base class to be reused as needed.
Uses deterministic hash for the batch path that doesn't change between sessions