Skip to content

Commit

Permalink
Merge pull request #17107 from jdavcs/23.2_filename_dswrapper
Browse files Browse the repository at this point in the history
[23.2] Expose file_name property in DatasetFilenameWrapper
  • Loading branch information
nsoranzo authored Dec 2, 2023
2 parents 779b051 + 33ccacf commit 6fc2e19
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
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

0 comments on commit 6fc2e19

Please sign in to comment.