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.2] Expose file_name property in DatasetFilenameWrapper #17107

Merged
merged 4 commits into from
Dec 2, 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
9 changes: 5 additions & 4 deletions lib/galaxy/tools/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,12 @@ def __str__(self) -> str:
else:
return str(self.unsanitized.get_file_name())

@property
def file_name(self) -> str:
return str(self)

def __getattr__(self, key: Any) -> Any:
if self.false_path is not None and key == "get_file_name":
# Path to dataset was rewritten for this job.
return lambda *args, **kwargs: self.false_path
elif key in ("extra_files_path", "files_path"):
if key in ("extra_files_path", "files_path"):
if not self.compute_environment:
# Only happens in WrappedParameters context, refactor!
return self.unsanitized.extra_files_path
Expand Down
2 changes: 1 addition & 1 deletion test/functional/tools/md5sum.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<tool id="md5sum" name="md5sum" version="1.0.0">
<command>
cp $input $output
cp '$input.file_name' '$output'
</command>
<inputs>
<param name="input" type="data" format="txt" />
Expand Down
4 changes: 2 additions & 2 deletions test/unit/app/tools/test_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def test_dataset_wrapper():
dataset = cast(DatasetInstance, MockDataset())
wrapper = DatasetFilenameWrapper(dataset)
assert str(wrapper) == MOCK_DATASET_PATH
assert wrapper.get_file_name() == MOCK_DATASET_PATH
assert wrapper.file_name == MOCK_DATASET_PATH

assert wrapper.ext == MOCK_DATASET_EXT

Expand All @@ -219,7 +219,7 @@ def test_dataset_wrapper_false_path():
dataset, compute_environment=cast(ComputeEnvironment, MockComputeEnvironment(false_path=new_path))
)
assert str(wrapper) == new_path
assert wrapper.get_file_name() == new_path
assert wrapper.file_name == new_path


class MockComputeEnvironment:
Expand Down
2 changes: 1 addition & 1 deletion tools/data_source/upload.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#while $varExists('output%i' % $outnum):
#set $output = $getVar('output%i' % $outnum)
#set $outnum += 1
#set $file_name = $output.get_file_name()
#set $file_name = str($output)
## FIXME: This is not future-proof for other uses of external_filename (other than for use by the library upload's "link data" feature)
#if $output.dataset.dataset.external_filename:
#set $file_name = "None"
Expand Down
Loading