Skip to content

Commit

Permalink
fix(kedro.hooks.artifacts): fix file permissions after input setup
Browse files Browse the repository at this point in the history
  • Loading branch information
lariel-fernandes committed Oct 11, 2024
1 parent 3591a27 commit 7499f11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mlopus/kedro/hooks/mlflow_artifacts/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def setup(self, default_run_id: str) -> _LineageArg:
mode="link" if self.link else "copy",
)

if self.path.is_dir() and not self.link:
paths.rchmod(self.path, paths.Mode.rwx)
if not self.link:
paths.chmod(self.path, paths.Mode.rwx)

return lineage_arg
8 changes: 8 additions & 0 deletions src/mlopus/utils/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ def place_path(src: PathLike, tgt: PathLike, mode: PathOperation, overwrite: boo
raise NotImplementedError(f"mode='{mode}'")


def chmod(path: PathLike, mode: int):
"""Apply chmod to file or directory."""
if (path := Path(path)).is_dir():
rchmod(path, mode)
else:
path.chmod(mode)


def rchmod(path: PathLike, mode: int):
"""Apply recursive chmod to directory."""
if not (path := Path(path)).is_dir():
Expand Down

0 comments on commit 7499f11

Please sign in to comment.