-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add options to cancel jobs, redo existing large images, and not force jobs #1586
Conversation
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.
Overall looks good. I have a few thoughts on simplifying things but will defer to @manthey
.param('createJobs', 'Whether job(s) should be used to create each ' | ||
'large image. Select true to use a job if needed, false to ' | ||
'never use a job, and always to always use a job.', | ||
required=False, default='false', dataType='string', | ||
enum=['true', 'false', 'always']) |
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.
Based on @manthey 's description in #1139 I get the impression this should be split into two options.
ie 'force' for always and 'localJob' making both boolean as seen here:
large_image/girder/girder_large_image/rest/tiles.py
Lines 199 to 205 in 56193ce
.param('force', 'Always use a job to create the large image.', | |
dataType='boolean', default=False, required=False) | |
.param('notify', 'If a job is required to create the large image, ' | |
'a nofication can be sent when it is complete.', | |
dataType='boolean', default=True, required=False) | |
.param('localJob', 'If true, run as a local job; if false, run via ' | |
'the remote worker', dataType='boolean', required=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.
The endpoint's previous iteration had separate 'force' and 'localJobs' parameters, then createJobs would be set to either True or 'always' internally, as seen below. We still might not want to create jobs at all, so @manthey suggested the endpoint's parameter accept a third state. The string to boolean conversion is not my favorite, though.
createJobs = 'always' if self.boolParam('force', params, default=False) else True |
default=False, dataType='boolean') | ||
.param('recurse', 'Whether child folders should be recursed.', required=False, | ||
default=False, dataType='boolean') | ||
.param('recurse', 'Whether child folders should be recursed.', |
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 generally prefer definitions not to include the option unless very self-explanatory. Perhaps something like:
'If true, images in child folders will also be checked'
Also as a personal preference I would change the descriptions from 'Whether...' to 'If...'
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.
That reads clearer and explaining what happens depending on what the user selects is a good idea. Change made here.
recurse=params.get('recurse'), createJobs=createJobs, | ||
localJobs=params.get('localJobs'), | ||
cancelJobs=params.get('cancelJobs'), | ||
redo=params.get('redoExisting')) |
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 breaking the options apart as suggested above would allow you to simplify this.
|
||
def createLargeImagesRecurse( | ||
self, folder, user, recurse, createJobs, localJobs, cancelJobs, redo): | ||
result = {'childFoldersRecursed': 0, | ||
'itemsSkipped': 0, | ||
'jobsCanceled': 0, | ||
'jobsFailedToCancel': 0, | ||
'largeImagesCreated': 0, | ||
'largeImagesRemovedAndRecreated': 0, | ||
'totalItems': 0} | ||
if recurse: | ||
for childFolder in Folder().childFolders(parent=folder, parentType='folder'): | ||
result['childFoldersRecursed'] += 1 | ||
childResult = self.createImagesRecurseOption(folder=childFolder, | ||
createJobs=createJobs, user=user, | ||
recurse=recurse, localJobs=localJobs) | ||
childResult = self.createLargeImagesRecurse(folder=childFolder, user=user, | ||
recurse=recurse, createJobs=createJobs, | ||
localJobs=localJobs, | ||
cancelJobs=cancelJobs, redo=redo) |
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 feels logically backwards to me. I think I would expect:
def createLargeImage(self, folder):
for item in folder:
***createImage logic here***
def folderRecurse(self, params):
if recurse:
for childFolder in folder:
createLargeImage()
additionally I am not sure I would make a new function to check the recurse param. That is a design choice for you and David to decide though.
6ce57a0
to
e22df94
Compare
This adds two more options from #1139 to the PUT large_image/folder/{id}/tiles endpoint, and allows the createJobs filter to accept three states. The first flag allows cancelling unfinished large image jobs related to items in the folder, so the large image can then be removed and a new one created. The second gives the option to remove and redo existing large images in the folder. The three states createJobs now accepts can either never use a job, use one only if needed, or force one for every large image.