Skip to content

Commit

Permalink
Compare metadata through _metadata for HDAH objects
Browse files Browse the repository at this point in the history
HistoryDatasetsAssoicationHistory objects don't have the full blown metadata
objects, instead we compare the raw JSON dumped into the database.
  • Loading branch information
mvdbeek committed Dec 31, 2017
1 parent 409fa01 commit c88d882
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
14 changes: 7 additions & 7 deletions lib/galaxy/managers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,22 @@ def __search(self, tool_id, tool_version, user, input_data, input_ids=None, job_
a.dataset_id == b.id,
c.dataset_id == b.dataset_id,
c.id == v, # c is the requested job input HDA
# We can only compare input dataset names and metadata for a job
# if we know that the input dataset hasn't changed since the job was run.
# This is relatively strict, we may be able to lift this requirement if we record the jobs'
# relevant parameters as JobParameters in the database
# We can compare input dataset names and metadata for a job
# if we know that the input dataset hasn't changed since the job was run,
# or if the job recorded a dataset_version and name and metadata of the current
# job request matches those that were recorded for the job in question (introduced in release 18.01)
or_(and_(
b.update_time < model.Job.create_time,
b.name == c.name,
b.extension == c.extension,
b._metadata == c._metadata,
b.metadata == c.metadata,
), and_(
b.id == e.history_dataset_association_id,
a.dataset_version == e.version,
e.name == c.name,
e.extension == c.extension,
e.metadata == c._metadata,
)),
e._metadata == c._metadata,
)),
or_(b.deleted == false(), c.deleted == false())
))
if identifier:
Expand Down
7 changes: 6 additions & 1 deletion lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2675,7 +2675,12 @@ def __init__(self,
self.version = version
self.extension = extension
self.extended_metadata_id = extended_metadata_id
self.metadata = metadata
if isinstance(metadata['dbkey'], list):
# The dbkey may or may not be stored in a list.
# To facilitate comparison we use the raw value
metadata = metadata.copy()
metadata['dbkey'] = metadata['dbkey'][0]
self._metadata = metadata


class HistoryDatasetAssociationDisplayAtAuthorization(object):
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/model/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
Column("version", Integer),
Column("name", TrimmedString(255)),
Column("extension", TrimmedString(64)),
Column("metadata", MetadataType()),
Column("metadata", MetadataType(), key="_metadata"),
Column("extended_metadata_id", Integer, ForeignKey("extended_metadata.id"), index=True),
)

Expand Down

0 comments on commit c88d882

Please sign in to comment.