Skip to content

Commit

Permalink
Refactor set_peek and move exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed May 27, 2024
1 parent 11ae179 commit 3cd64e7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
7 changes: 1 addition & 6 deletions lib/galaxy/jobs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1788,12 +1788,7 @@ def _finish_dataset(self, output_name, dataset, job, context, final_job_state, r
)
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"
Expand Down
7 changes: 1 addition & 6 deletions lib/galaxy/metadata/set_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,7 @@ def set_meta(new_dataset_instance, file_dict):
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]
Expand Down
12 changes: 10 additions & 2 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4652,8 +4652,16 @@ def get_mime(self):
# 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)
Expand Down

0 comments on commit 3cd64e7

Please sign in to comment.