-
Notifications
You must be signed in to change notification settings - Fork 0
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
Change labels #229
base: main
Are you sure you want to change the base?
Change labels #229
Conversation
shravani-whoi
commented
Jun 9, 2022
- Based on an input csv accessible via /rois that has mapping of Old label -> New Label
- Status output is written to a new CSV in the /rois folder. The 'UpdatedRowCount' column added here shows the number of rows that have been updated with the new label name.
if not os.path.exists(mapping_csv): | ||
raise CommandError('specified file does not exist') | ||
with open(mapping_csv,'r') as csvin: | ||
with open('/rois/output.csv', 'w') as csvout: |
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.
replace hardcoded pathname with parameter. larger issue: do we need to write out a status CSV or can we simply produce logging output?
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.
Sure. I can take a variable for the output.csv if we decide to go that route, as discussed in the comment below
|
||
for row in reader: | ||
res = 0 | ||
res = Label.objects.filter(name=row[0]).update(name=row[1]) |
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 error handling; in the case that the provided source label does not exist, this should be treated as a failure and reported to the user instead of silently taking no action.
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.
So this is the reason I am generating an output file. The update() calls returns a 0, not an error when provided source label doesn't exist. And I just thought filtering through rows containing 0 in the UpdateRowCount column is easier to track than going through multiple error logs in the output (Might miss seeing some). This way, we go through all keys, instead of interrupting when one error occurs in the middle. But happy to change if this is an overkill.
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.
In the above image, none of the labels matched.