Skip to content

Commit

Permalink
Draft.
Browse files Browse the repository at this point in the history
  • Loading branch information
riga committed Jul 23, 2024
1 parent 2f942bf commit f85eaef
Show file tree
Hide file tree
Showing 7 changed files with 446 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 @@ -72,6 +73,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
10 changes: 8 additions & 2 deletions law/target/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,11 @@ class FileSystemDirectoryTarget(FileSystemTarget):

open = None

def _child_args(self, path: str | pathlib.Path) -> tuple[tuple[Any, ...], dict[str, Any]]:
def _child_args(
self,
path: str | pathlib.Path,
type: str,
) -> tuple[tuple[Any, ...], dict[str, Any]]:
return (), {}

def child(
Expand Down Expand Up @@ -557,10 +561,12 @@ def child(
raise Exception(f"cannot guess type of non-existing path '{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
8 changes: 6 additions & 2 deletions law/target/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,12 @@ def localize(

class LocalDirectoryTarget(FileSystemDirectoryTarget, LocalTarget):

def _child_args(self, path: str | pathlib.Path) -> tuple[tuple[Any, ...], dict[str, Any]]:
args, kwargs = super(LocalDirectoryTarget, self)._child_args(path)
def _child_args(
self,
path: str | pathlib.Path,
ype: str,
) -> tuple[tuple[Any, ...], dict[str, Any]]:
args, kwargs = super(LocalDirectoryTarget, self)._child_args(path, type)
kwargs["fs"] = self.fs
return args, kwargs

Expand Down
Loading

0 comments on commit f85eaef

Please sign in to comment.