-
Notifications
You must be signed in to change notification settings - Fork 13
fixing parents in pfb > tsv > pfb conversions #113
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
Conversation
Avantol13
left a comment
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.
See comments. Also, can you expand the PR description bug fix to briefly describe the specific issue you're fixing?
src/pfb/exporters/tsv.py
Outdated
| from ..cli import to_command | ||
|
|
||
| plural_parents = { | ||
| "subjects":"subject", |
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.
does this repo not run wool checks? It must not, can you run the black style formatter over this?
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.
And if you have time, I wouldn't mind if you added the wool check, but I understand that's somewhat out of scope
src/pfb/exporters/tsv.py
Outdated
|
|
||
| from ..cli import to_command | ||
|
|
||
| plural_parents = { |
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.
PLURAL_PARENTS all caps underscore naming convention for a const module global
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.
Should this be configurable rather than a constant global? is this data dictionary specific / have we handled all the cases we know about?
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.
These parents node names are part of the minimal data model. Any nodes that are down stream from these top level nodes do not have any problems. I believe it should be fine to just have this as a global constant.
src/pfb/exporters/tsv.py
Outdated
| parent_node = r["dst_name"] | ||
| parent_id = r["dst_id"] | ||
|
|
||
| if parent_node in plural_parents: |
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.
this is an unnecessary, nit-picky, fancy, one-liner suggestion. But honestly I think your way is more readable
parent_node = plural_parents.get(parent_node, parent_node)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.
I think we should keep it readable. If people are going to work with PFBs I think what was written is sufficient. Both lines are O(1) anyways.
Bug Fixes
fixing issue with going from PFB -> TSVs -> PFB. When translating from a PFB to TSV files and then back to a PFB file the parent names of the nodes are in plural format. They should be in singular form according to the dictionary. This only happens with the top level parents that are a part of the minimal data model.