From cdc6e60a1cf6b7aa4b869c7ee784f8fbd8a1e402 Mon Sep 17 00:00:00 2001 From: Rafal Wojdyla Date: Thu, 14 Apr 2022 13:42:33 +0200 Subject: [PATCH] Handle main_dir in staging --- articat/fs_artifact.py | 7 +++++-- articat/tests/fs_artifact_test.py | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/articat/fs_artifact.py b/articat/fs_artifact.py index 5330325..aacc180 100644 --- a/articat/fs_artifact.py +++ b/articat/fs_artifact.py @@ -73,9 +73,12 @@ def main_dir(self) -> str: """ # to not worry about presence of scheme, we remove the prefix # and add it back - if self.files_dir: + if self._file_prefix is not None: + return self._file_prefix + elif self.files_dir: return self.files_dir - # TODO: remove this code path + # TODO: remove this code path, for this to be safe to remove + # we need to update legacy artifacts first (or remove them) # This is the legacy handling of the main_dir, where we gather # main dir from the files_pattern assert self.files_pattern is not None diff --git a/articat/tests/fs_artifact_test.py b/articat/tests/fs_artifact_test.py index c579d7e..83fa5ae 100644 --- a/articat/tests/fs_artifact_test.py +++ b/articat/tests/fs_artifact_test.py @@ -26,6 +26,7 @@ def test_fs_artifact_join_paths_works(uid: ID) -> None: with fsspec.open(p, "w") as f: f.write("ala ma kota") a.files_pattern = None + assert a.main_dir == a.staging_file_prefix assert p == f"{a.staging_file_prefix}/data.dat" assert a._file_prefix is None p = a.joinpath("data.dat")