Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Change labels #229

wants to merge 4 commits into from

Conversation

shravani-whoi
Copy link
Collaborator

  • 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:
Copy link
Contributor

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?

Copy link
Collaborator Author

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])
Copy link
Contributor

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.

Copy link
Collaborator Author

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.
Screen Shot 2022-06-09 at 12 39 18 PM

Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants