Skip to content

Commit

Permalink
Merge pull request #18231 from mvdbeek/set_peek_on_success_only
Browse files Browse the repository at this point in the history
[24.0] Don't set dataset peek for errored jobs
  • Loading branch information
jmchilton authored May 27, 2024
2 parents fef8341 + 54db4e9 commit 62b53c5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
8 changes: 6 additions & 2 deletions lib/galaxy/datatypes/molecules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1546,8 +1546,12 @@ def sniff_prefix(self, file_prefix: FilePrefix) -> bool:
def set_peek(self, dataset: DatasetProtocol, **kwd) -> None:
if not dataset.dataset.purged:
dataset.peek = get_file_peek(dataset.get_file_name())
atom_number = int(dataset.peek.split("\n")[1])
dataset.blurb = f"{atom_number} atoms"
peek_lines = dataset.peek.split("\n")
try:
atom_number = int(peek_lines[1])
dataset.blurb = f"{atom_number} atoms"
except (ValueError, IndexError):
dataset.blurb = "file does not look like valid GRO file."
else:
dataset.peek = "file does not exist"
dataset.blurb = "file purged from disk"
Expand Down
8 changes: 2 additions & 6 deletions lib/galaxy/jobs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1786,13 +1786,9 @@ def _finish_dataset(self, output_name, dataset, job, context, final_job_state, r
working_directory=self.working_directory,
remote_metadata_directory=remote_metadata_directory,
)
line_count = context.get("line_count", None)
try:
# Certain datatype's set_peek methods contain a line_count argument
if final_job_state != job.states.ERROR:
line_count = context.get("line_count", None)
dataset.set_peek(line_count=line_count)
except TypeError:
# ... and others don't
dataset.set_peek()
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 62b53c5

Please sign in to comment.