Skip to content

Commit

Permalink
Add mirrored targets.
Browse files Browse the repository at this point in the history
  • Loading branch information
riga committed Jul 23, 2024
1 parent 6c714a8 commit f4a0203
Show file tree
Hide file tree
Showing 7 changed files with 434 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/api/target/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ law.target
local
remote
collection
mirrored
formatter
27 changes: 27 additions & 0 deletions docs/api/target/mirrored.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
law.target.mirrored
===================

.. automodule:: law.target.mirrored

.. contents::


Class ``MirroredTarget``
------------------------

.. autoclass:: MirroredTarget
:members:


Class ``MirroredFileTarget``
----------------------------

.. autoclass:: MirroredFileTarget
:members:


Class ``MirroredDirectoryTarget``
---------------------------------

.. autoclass:: MirroredDirectoryTarget
:members:
2 changes: 2 additions & 0 deletions law/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"FileSystemTarget", "FileSystemFileTarget", "FileSystemDirectoryTarget",
"LocalFileSystem", "LocalTarget", "LocalFileTarget", "LocalDirectoryTarget",
"TargetCollection", "FileCollection", "SiblingFileCollection", "NestedSiblingFileCollection",
"MirroredTarget", "MirroredFileTarget", "MirroredDirectoryTarget",
"Sandbox", "BashSandbox", "VenvSandbox",
"BaseJobManager", "BaseJobFileFactory", "JobInputFile", "JobArguments",
"NO_STR", "NO_INT", "NO_FLOAT", "is_no_param", "get_param", "Parameter",
Expand Down Expand Up @@ -75,6 +76,7 @@
from law.target.collection import (
TargetCollection, FileCollection, SiblingFileCollection, NestedSiblingFileCollection,
)
from law.target.mirrored import MirroredTarget, MirroredFileTarget, MirroredDirectoryTarget
import law.decorator
from law.task.base import Register, Task, WrapperTask, ExternalTask
from law.workflow.base import (
Expand Down
6 changes: 4 additions & 2 deletions law/target/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ class FileSystemDirectoryTarget(FileSystemTarget):

open = None

def _child_args(self, path):
def _child_args(self, path, type):
return (), {}

def child(self, path, type=None, mktemp_pattern=False, **kwargs):
Expand All @@ -370,10 +370,12 @@ def child(self, path, type=None, mktemp_pattern=False, **kwargs):
raise Exception("cannot guess type of non-existing path '{}'".format(path))
elif self.fs.isdir(path):
cls = self.__class__
type = "d"
else:
cls = self.file_class
type = "f"

args, _kwargs = self._child_args(path)
args, _kwargs = self._child_args(path, type)
_kwargs.update(kwargs)

return cls(unexpanded_path, *args, **_kwargs)
Expand Down
4 changes: 2 additions & 2 deletions law/target/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,8 @@ def localize(self, mode="r", perm=None, dir_perm=None, tmp_dir=None, **kwargs):

class LocalDirectoryTarget(FileSystemDirectoryTarget, LocalTarget):

def _child_args(self, path):
args, kwargs = super(LocalDirectoryTarget, self)._child_args(path)
def _child_args(self, path, type):
args, kwargs = super(LocalDirectoryTarget, self)._child_args(path, type)
kwargs["fs"] = self.fs
return args, kwargs

Expand Down
Loading

0 comments on commit f4a0203

Please sign in to comment.