-
Notifications
You must be signed in to change notification settings - Fork 12
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
Annotation class attrs #123
base: main
Are you sure you want to change the base?
Annotation class attrs #123
Conversation
The `_parse_scalar` was never called for the vector arguments. The parse vectorlist iteration was made simpler
…om classmethod Since the ET cant be parsed if the file doesnt exist, not clear how the check would fail
if it were a classmethod, it should return a new instance of a class, but this returns a `SimpleNamespace`
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.
Thanks for the PR @scottstanie. I think the updates here are important to avoid the race condition when concurrent threads exists like the example you posted here.
Here are my comments and suggestions - Seongsu
src/s1reader/s1_annotation.py
Outdated
cls.number_of_samples = \ | ||
cls._parse_scalar('imageAnnotation/imageInformation/numberOfSamples', | ||
number_of_samples = \ | ||
cls._parse_scalar(et_in, | ||
'imageAnnotation/imageInformation/numberOfSamples', | ||
'scalar_int') | ||
cls.number_of_samples = \ | ||
cls._parse_scalar('imageAnnotation/imageInformation/numberOfSamples', | ||
number_of_samples = \ | ||
cls._parse_scalar(et_in, | ||
'imageAnnotation/imageInformation/numberOfSamples', | ||
'scalar_int') |
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 like it's my bad again. It seems like that we have a duplicate here.
Co-authored-by: Seongsu Jeong <[email protected]>
This is trying to prevent #122 from popping up sporadically.
This is changing the
classmethod
s in the annotation module to return instances: https://stackoverflow.com/a/14605349/4174466All functions that are decorated with
@classmethod
are supposed to be alternate constructors (in addition to__init__
); that is, they're meant to create a new instance. Right now, they have been changing "class attributes", which are shared across all instances of that class, and they are returning the class itself.Why this is a problem
If we kick of many instance of COMPASS in different threads, each one that reads bursts instantiates these annotation classes. they are all changing the same class attribute, so it's a data race where difference function calls to
.from_et
can clobber each other.(example to show what this looks like)
if you try to do this method in many threads: