Skip to content
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

[23.1] Skip change_datatype things if we're not actually changing the extension #16931

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/galaxy/datatypes/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,13 +590,14 @@ def get_datatype_by_extension(self, ext):
return self.datatypes_by_extension.get(ext, None)

def change_datatype(self, data, ext):
data.extension = ext
# call init_meta and copy metadata from itself. The datatype
# being converted *to* will handle any metadata copying and
# initialization.
if data.has_data():
data.set_size()
data.init_meta(copy_from=data)
if data.extension != ext:
data.extension = ext
# call init_meta and copy metadata from itself. The datatype
# being converted *to* will handle any metadata copying and
# initialization.
if data.has_data():
data.set_size()
data.init_meta(copy_from=data)
return data

def load_datatype_converters(self, toolbox, use_cached=False):
Expand Down
11 changes: 10 additions & 1 deletion lib/galaxy/model/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,16 @@ def wrap(self, value, session):
if isinstance(value, int):
return session.query(galaxy.model.MetadataFile).get(value)
else:
return session.query(galaxy.model.MetadataFile).filter_by(uuid=value).one()
wrapped_value = session.query(galaxy.model.MetadataFile).filter_by(uuid=value).one_or_none()
jdavcs marked this conversation as resolved.
Show resolved Hide resolved
if wrapped_value:
return wrapped_value
else:
# If we've simultaneously copied the dataset and we've changed the datatype on the
# copy we may not have committed the MetadataFile yet, so we need to commit the session.
# TODO: It would be great if we can avoid the commit in the future.
with transaction(session):
session.commit()
return session.query(galaxy.model.MetadataFile).filter_by(uuid=value).one_or_none()

def make_copy(self, value, target_context: MetadataCollection, source_context):
session = target_context._object_session(target_context.parent)
Expand Down
Loading