-
Notifications
You must be signed in to change notification settings - Fork 4
New function to correct subject ids #27
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
base: main
Are you sure you want to change the base?
New function to correct subject ids #27
Conversation
run_subject_id_correction.py
Outdated
|
||
def all_corrected(): | ||
|
||
record = "2d2wf-j0256" |
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'd like the test to create the test record.
return False | ||
print("All subject ids were added") | ||
return True | ||
|
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.
Add a test where a record has some subjects that aren't being edited
Also add your info to the codemeta.json file, like you did for caltechdata_api |
|
||
metadata = get_metadata( | ||
record, | ||
production=False, |
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.
You're going to need to set this based on the test
variable (or change it to `production for consistency)
metadata = get_metadata( | ||
record, | ||
production=False, | ||
validate=True, |
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.
You don't need to include anything that's a default.
authors=False, | ||
) | ||
|
||
print(metadata["subjects"]) |
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 can be removed
new_subjects = [] | ||
|
||
for subject_entry in metadata["subjects"]: | ||
subject_name = subject_entry["subject"].strip().lower() |
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.
Why are you comparing based on a lowercase version of the subject? We want to compare based on what's in the repository.
@@ -0,0 +1,189 @@ | |||
import unittest | |||
import os, copy, time, requests | |||
from run_subject_id_correction import all_corrected |
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 thought this was going to move into this file?
authors=False, | ||
) | ||
|
||
for subject_idx in range(len(record_metadata["subjects"])): |
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 looks like test code that should be in the tests
from run_subject_id_correction import all_corrected | ||
from caltechdata_api import caltechdata_write, get_metadata | ||
|
||
os.environ["RDMTOK"] = "FVyjwsxBvfNXm5NmmfL8fKGI8hhA6puT9pNJO8PAyrLlNYdeMjfjhBVvuhbs" |
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.
Remove this and delete the token in the test system
Implemented a new function to correct subject ids in caltechdata.