mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-19 02:21:32 +08:00
Refactor set_peek and move exception handling
This commit is contained in:
@@ -1788,12 +1788,7 @@ class MinimalJobWrapper(HasResourceParameters):
|
||||
)
|
||||
if final_job_state != job.states.ERROR:
|
||||
line_count = context.get("line_count", None)
|
||||
try:
|
||||
# Certain datatype's set_peek methods contain a line_count argument
|
||||
dataset.set_peek(line_count=line_count)
|
||||
except TypeError:
|
||||
# ... and others don't
|
||||
dataset.set_peek()
|
||||
dataset.set_peek(line_count=line_count)
|
||||
else:
|
||||
# Handle purged datasets.
|
||||
dataset.blurb = "empty"
|
||||
|
||||
@@ -506,12 +506,7 @@ def set_metadata_portable(
|
||||
dataset.dataset.uuid = context["uuid"]
|
||||
if not final_job_state == Job.states.ERROR:
|
||||
line_count = context.get("line_count", None)
|
||||
try:
|
||||
# Certain datatype's set_peek methods contain a line_count argument
|
||||
dataset.set_peek(line_count=line_count)
|
||||
except TypeError:
|
||||
# ... and others don't
|
||||
dataset.set_peek()
|
||||
dataset.set_peek(line_count=line_count)
|
||||
for context_key in TOOL_PROVIDED_JOB_METADATA_KEYS:
|
||||
if context_key in context:
|
||||
context_value = context[context_key]
|
||||
|
||||
@@ -4652,8 +4652,16 @@ class DatasetInstance(RepresentById, UsesCreateAndUpdateTime, _HasTable):
|
||||
# extension is None
|
||||
return "data"
|
||||
|
||||
def set_peek(self, **kwd):
|
||||
return self.datatype.set_peek(self, **kwd)
|
||||
def set_peek(self, line_count=None, **kwd):
|
||||
try:
|
||||
# Certain datatype's set_peek methods contain a line_count argument
|
||||
return self.datatype.set_peek(self, line_count=line_count, **kwd)
|
||||
except TypeError:
|
||||
# ... and others don't
|
||||
return self.datatype.set_peek(self, **kwd)
|
||||
except Exception:
|
||||
# Never fail peek setting, but do log exception so datatype logic can be fixed
|
||||
log.exception("Setting peek failed")
|
||||
|
||||
def init_meta(self, copy_from=None):
|
||||
return self.datatype.init_meta(self, copy_from=copy_from)
|
||||
|
||||
Reference in New Issue
Block a user