Add files using upload-large-folder tool
Browse files- tool_server/.venv/lib/python3.12/site-packages/einops/experimental/__init__.py +0 -0
- tool_server/.venv/lib/python3.12/site-packages/einops/experimental/indexing.py +5 -0
- tool_server/.venv/lib/python3.12/site-packages/einops/layers/__init__.py +106 -0
- tool_server/.venv/lib/python3.12/site-packages/einops/layers/_einmix.py +229 -0
- tool_server/.venv/lib/python3.12/site-packages/einops/layers/flax.py +82 -0
- tool_server/.venv/lib/python3.12/site-packages/einops/layers/keras.py +9 -0
- tool_server/.venv/lib/python3.12/site-packages/filelock-3.19.1.dist-info/licenses/LICENSE +24 -0
- tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/_api.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/_error.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/_soft.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/_unix.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/_util.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/_windows.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/asyncio.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/version.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/frozenlist-1.7.0.dist-info/licenses/LICENSE +201 -0
- tool_server/.venv/lib/python3.12/site-packages/frozenlist/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec-2025.9.0.dist-info/licenses/LICENSE +29 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/gist.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/git.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/github.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/http.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/http_sync.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/jupyter.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/libarchive.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/local.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/memory.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/reference.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/sftp.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/smb.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/tar.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/webhdfs.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/zip.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__init__.py +289 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/common.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/copy.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/get.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/mv.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/open.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/pipe.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/put.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/common.py +175 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/copy.py +557 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/get.py +587 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/mv.py +57 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/open.py +11 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/pipe.py +11 -0
- tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/put.py +591 -0
tool_server/.venv/lib/python3.12/site-packages/einops/experimental/__init__.py
ADDED
|
File without changes
|
tool_server/.venv/lib/python3.12/site-packages/einops/experimental/indexing.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
This file contained some thoughts on indexing.
|
| 3 |
+
|
| 4 |
+
These ideas were developed further in eindex (separate package).
|
| 5 |
+
"""
|
tool_server/.venv/lib/python3.12/site-packages/einops/layers/__init__.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__author__ = "Alex Rogozhnikov"
|
| 2 |
+
|
| 3 |
+
from typing import Any, Dict
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
from ..einops import TransformRecipe, _apply_recipe, _prepare_recipes_for_all_dims, get_backend
|
| 7 |
+
from .. import EinopsError
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class RearrangeMixin:
|
| 11 |
+
"""
|
| 12 |
+
Rearrange layer behaves identically to einops.rearrange operation.
|
| 13 |
+
|
| 14 |
+
:param pattern: str, rearrangement pattern
|
| 15 |
+
:param axes_lengths: any additional specification of dimensions
|
| 16 |
+
|
| 17 |
+
See einops.rearrange for source_examples.
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
def __init__(self, pattern: str, **axes_lengths: Any) -> None:
|
| 21 |
+
super().__init__()
|
| 22 |
+
self.pattern = pattern
|
| 23 |
+
self.axes_lengths = axes_lengths
|
| 24 |
+
# self._recipe = self.recipe() # checking parameters
|
| 25 |
+
self._multirecipe = self.multirecipe()
|
| 26 |
+
self._axes_lengths = tuple(self.axes_lengths.items())
|
| 27 |
+
|
| 28 |
+
def __repr__(self) -> str:
|
| 29 |
+
params = repr(self.pattern)
|
| 30 |
+
for axis, length in self.axes_lengths.items():
|
| 31 |
+
params += ", {}={}".format(axis, length)
|
| 32 |
+
return "{}({})".format(self.__class__.__name__, params)
|
| 33 |
+
|
| 34 |
+
def multirecipe(self) -> Dict[int, TransformRecipe]:
|
| 35 |
+
try:
|
| 36 |
+
return _prepare_recipes_for_all_dims(
|
| 37 |
+
self.pattern, operation="rearrange", axes_names=tuple(self.axes_lengths)
|
| 38 |
+
)
|
| 39 |
+
except EinopsError as e:
|
| 40 |
+
raise EinopsError(" Error while preparing {!r}\n {}".format(self, e))
|
| 41 |
+
|
| 42 |
+
def _apply_recipe(self, x):
|
| 43 |
+
backend = get_backend(x)
|
| 44 |
+
return _apply_recipe(
|
| 45 |
+
backend=backend,
|
| 46 |
+
recipe=self._multirecipe[len(x.shape)],
|
| 47 |
+
tensor=x,
|
| 48 |
+
reduction_type="rearrange",
|
| 49 |
+
axes_lengths=self._axes_lengths,
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
def __getstate__(self):
|
| 53 |
+
return {"pattern": self.pattern, "axes_lengths": self.axes_lengths}
|
| 54 |
+
|
| 55 |
+
def __setstate__(self, state):
|
| 56 |
+
self.__init__(pattern=state["pattern"], **state["axes_lengths"])
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
class ReduceMixin:
|
| 60 |
+
"""
|
| 61 |
+
Reduce layer behaves identically to einops.reduce operation.
|
| 62 |
+
|
| 63 |
+
:param pattern: str, rearrangement pattern
|
| 64 |
+
:param reduction: one of available reductions ('min', 'max', 'sum', 'mean', 'prod'), case-sensitive
|
| 65 |
+
:param axes_lengths: any additional specification of dimensions
|
| 66 |
+
|
| 67 |
+
See einops.reduce for source_examples.
|
| 68 |
+
"""
|
| 69 |
+
|
| 70 |
+
def __init__(self, pattern: str, reduction: str, **axes_lengths: Any):
|
| 71 |
+
super().__init__()
|
| 72 |
+
self.pattern = pattern
|
| 73 |
+
self.reduction = reduction
|
| 74 |
+
self.axes_lengths = axes_lengths
|
| 75 |
+
self._multirecipe = self.multirecipe()
|
| 76 |
+
self._axes_lengths = tuple(self.axes_lengths.items())
|
| 77 |
+
|
| 78 |
+
def __repr__(self):
|
| 79 |
+
params = "{!r}, {!r}".format(self.pattern, self.reduction)
|
| 80 |
+
for axis, length in self.axes_lengths.items():
|
| 81 |
+
params += ", {}={}".format(axis, length)
|
| 82 |
+
return "{}({})".format(self.__class__.__name__, params)
|
| 83 |
+
|
| 84 |
+
def multirecipe(self) -> Dict[int, TransformRecipe]:
|
| 85 |
+
try:
|
| 86 |
+
return _prepare_recipes_for_all_dims(
|
| 87 |
+
self.pattern, operation=self.reduction, axes_names=tuple(self.axes_lengths)
|
| 88 |
+
)
|
| 89 |
+
except EinopsError as e:
|
| 90 |
+
raise EinopsError(" Error while preparing {!r}\n {}".format(self, e))
|
| 91 |
+
|
| 92 |
+
def _apply_recipe(self, x):
|
| 93 |
+
backend = get_backend(x)
|
| 94 |
+
return _apply_recipe(
|
| 95 |
+
backend=backend,
|
| 96 |
+
recipe=self._multirecipe[len(x.shape)],
|
| 97 |
+
tensor=x,
|
| 98 |
+
reduction_type=self.reduction,
|
| 99 |
+
axes_lengths=self._axes_lengths,
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
def __getstate__(self):
|
| 103 |
+
return {"pattern": self.pattern, "reduction": self.reduction, "axes_lengths": self.axes_lengths}
|
| 104 |
+
|
| 105 |
+
def __setstate__(self, state):
|
| 106 |
+
self.__init__(pattern=state["pattern"], reduction=state["reduction"], **state["axes_lengths"])
|
tool_server/.venv/lib/python3.12/site-packages/einops/layers/_einmix.py
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any, List, Optional, Dict
|
| 2 |
+
|
| 3 |
+
from einops import EinopsError
|
| 4 |
+
from einops.parsing import ParsedExpression, _ellipsis
|
| 5 |
+
import warnings
|
| 6 |
+
import string
|
| 7 |
+
from ..einops import _product
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def _report_axes(axes: set, report_message: str):
|
| 11 |
+
if len(axes) > 0:
|
| 12 |
+
raise EinopsError(report_message.format(axes))
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class _EinmixMixin:
|
| 16 |
+
def __init__(self, pattern: str, weight_shape: str, bias_shape: Optional[str] = None, **axes_lengths: Any):
|
| 17 |
+
"""
|
| 18 |
+
EinMix - Einstein summation with automated tensor management and axis packing/unpacking.
|
| 19 |
+
|
| 20 |
+
EinMix is a combination of einops and MLP, see tutorial:
|
| 21 |
+
https://github.com/arogozhnikov/einops/blob/main/docs/3-einmix-layer.ipynb
|
| 22 |
+
|
| 23 |
+
Imagine taking einsum with two arguments, one of each input, and one - tensor with weights
|
| 24 |
+
>>> einsum('time batch channel_in, channel_in channel_out -> time batch channel_out', input, weight)
|
| 25 |
+
|
| 26 |
+
This layer manages weights for you, syntax highlights a special role of weight matrix
|
| 27 |
+
>>> EinMix('time batch channel_in -> time batch channel_out', weight_shape='channel_in channel_out')
|
| 28 |
+
But otherwise it is the same einsum under the hood. Plus einops-rearrange.
|
| 29 |
+
|
| 30 |
+
Simple linear layer with a bias term (you have one like that in your framework)
|
| 31 |
+
>>> EinMix('t b cin -> t b cout', weight_shape='cin cout', bias_shape='cout', cin=10, cout=20)
|
| 32 |
+
There is no restriction to mix the last axis. Let's mix along height
|
| 33 |
+
>>> EinMix('h w c-> hout w c', weight_shape='h hout', bias_shape='hout', h=32, hout=32)
|
| 34 |
+
Example of channel-wise multiplication (like one used in normalizations)
|
| 35 |
+
>>> EinMix('t b c -> t b c', weight_shape='c', c=128)
|
| 36 |
+
Multi-head linear layer (each head is own linear layer):
|
| 37 |
+
>>> EinMix('t b (head cin) -> t b (head cout)', weight_shape='head cin cout', ...)
|
| 38 |
+
|
| 39 |
+
... and yes, you need to specify all dimensions of weight shape/bias shape in parameters.
|
| 40 |
+
|
| 41 |
+
Use cases:
|
| 42 |
+
- when channel dimension is not last, use EinMix, not transposition
|
| 43 |
+
- patch/segment embeddings
|
| 44 |
+
- when need only within-group connections to reduce number of weights and computations
|
| 45 |
+
- next-gen MLPs (follow tutorial link above to learn more!)
|
| 46 |
+
- in general, any time you want to combine linear layer and einops.rearrange
|
| 47 |
+
|
| 48 |
+
Uniform He initialization is applied to weight tensor.
|
| 49 |
+
This accounts for the number of elements mixed and produced.
|
| 50 |
+
|
| 51 |
+
Parameters
|
| 52 |
+
:param pattern: transformation pattern, left side - dimensions of input, right side - dimensions of output
|
| 53 |
+
:param weight_shape: axes of weight. A tensor of this shape is created, stored, and optimized in a layer
|
| 54 |
+
If bias_shape is not specified, bias is not created.
|
| 55 |
+
:param bias_shape: axes of bias added to output. Weights of this shape are created and stored. If `None` (the default), no bias is added.
|
| 56 |
+
:param axes_lengths: dimensions of weight tensor
|
| 57 |
+
"""
|
| 58 |
+
super().__init__()
|
| 59 |
+
self.pattern = pattern
|
| 60 |
+
self.weight_shape = weight_shape
|
| 61 |
+
self.bias_shape = bias_shape
|
| 62 |
+
self.axes_lengths = axes_lengths
|
| 63 |
+
self.initialize_einmix(
|
| 64 |
+
pattern=pattern, weight_shape=weight_shape, bias_shape=bias_shape, axes_lengths=axes_lengths
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
def initialize_einmix(self, pattern: str, weight_shape: str, bias_shape: Optional[str], axes_lengths: dict):
|
| 68 |
+
left_pattern, right_pattern = pattern.split("->")
|
| 69 |
+
left = ParsedExpression(left_pattern)
|
| 70 |
+
right = ParsedExpression(right_pattern)
|
| 71 |
+
weight = ParsedExpression(weight_shape)
|
| 72 |
+
_report_axes(
|
| 73 |
+
set.difference(right.identifiers, {*left.identifiers, *weight.identifiers}),
|
| 74 |
+
"Unrecognized identifiers on the right side of EinMix {}",
|
| 75 |
+
)
|
| 76 |
+
if weight.has_ellipsis:
|
| 77 |
+
raise EinopsError("Ellipsis is not supported in weight, as its shape should be fully specified")
|
| 78 |
+
if left.has_ellipsis or right.has_ellipsis:
|
| 79 |
+
if not (left.has_ellipsis and right.has_ellipsis):
|
| 80 |
+
raise EinopsError(f"Ellipsis in EinMix should be on both sides, {pattern}")
|
| 81 |
+
if left.has_ellipsis_parenthesized:
|
| 82 |
+
raise EinopsError(f"Ellipsis on left side can't be in parenthesis, got {pattern}")
|
| 83 |
+
if any(x.has_non_unitary_anonymous_axes for x in [left, right, weight]):
|
| 84 |
+
raise EinopsError("Anonymous axes (numbers) are not allowed in EinMix")
|
| 85 |
+
if "(" in weight_shape or ")" in weight_shape:
|
| 86 |
+
raise EinopsError(f"Parenthesis is not allowed in weight shape: {weight_shape}")
|
| 87 |
+
|
| 88 |
+
pre_reshape_pattern = None
|
| 89 |
+
pre_reshape_lengths = None
|
| 90 |
+
post_reshape_pattern = None
|
| 91 |
+
if any(len(group) != 1 for group in left.composition):
|
| 92 |
+
names: List[str] = []
|
| 93 |
+
for group in left.composition:
|
| 94 |
+
names += group
|
| 95 |
+
names = [name if name != _ellipsis else "..." for name in names]
|
| 96 |
+
composition = " ".join(names)
|
| 97 |
+
pre_reshape_pattern = f"{left_pattern}-> {composition}"
|
| 98 |
+
pre_reshape_lengths = {name: length for name, length in axes_lengths.items() if name in names}
|
| 99 |
+
|
| 100 |
+
if any(len(group) != 1 for group in right.composition) or right.has_ellipsis_parenthesized:
|
| 101 |
+
names = []
|
| 102 |
+
for group in right.composition:
|
| 103 |
+
names += group
|
| 104 |
+
names = [name if name != _ellipsis else "..." for name in names]
|
| 105 |
+
composition = " ".join(names)
|
| 106 |
+
post_reshape_pattern = f"{composition} ->{right_pattern}"
|
| 107 |
+
|
| 108 |
+
self._create_rearrange_layers(pre_reshape_pattern, pre_reshape_lengths, post_reshape_pattern, {})
|
| 109 |
+
|
| 110 |
+
for axis in weight.identifiers:
|
| 111 |
+
if axis not in axes_lengths:
|
| 112 |
+
raise EinopsError("Dimension {} of weight should be specified".format(axis))
|
| 113 |
+
_report_axes(
|
| 114 |
+
set.difference(set(axes_lengths), {*left.identifiers, *weight.identifiers}),
|
| 115 |
+
"Axes {} are not used in pattern",
|
| 116 |
+
)
|
| 117 |
+
_report_axes(
|
| 118 |
+
set.difference(weight.identifiers, {*left.identifiers, *right.identifiers}), "Weight axes {} are redundant"
|
| 119 |
+
)
|
| 120 |
+
if len(weight.identifiers) == 0:
|
| 121 |
+
warnings.warn("EinMix: weight has no dimensions (means multiplication by a number)")
|
| 122 |
+
|
| 123 |
+
_weight_shape = [axes_lengths[axis] for (axis,) in weight.composition]
|
| 124 |
+
# single output element is a combination of fan_in input elements
|
| 125 |
+
_fan_in = _product([axes_lengths[axis] for (axis,) in weight.composition if axis not in right.identifiers])
|
| 126 |
+
if bias_shape is not None:
|
| 127 |
+
# maybe I should put ellipsis in the beginning for simplicity?
|
| 128 |
+
if not isinstance(bias_shape, str):
|
| 129 |
+
raise EinopsError("bias shape should be string specifying which axes bias depends on")
|
| 130 |
+
bias = ParsedExpression(bias_shape)
|
| 131 |
+
_report_axes(
|
| 132 |
+
set.difference(bias.identifiers, right.identifiers),
|
| 133 |
+
"Bias axes {} not present in output",
|
| 134 |
+
)
|
| 135 |
+
_report_axes(
|
| 136 |
+
set.difference(bias.identifiers, set(axes_lengths)),
|
| 137 |
+
"Sizes not provided for bias axes {}",
|
| 138 |
+
)
|
| 139 |
+
|
| 140 |
+
_bias_shape = []
|
| 141 |
+
used_non_trivial_size = False
|
| 142 |
+
for axes in right.composition:
|
| 143 |
+
if axes == _ellipsis:
|
| 144 |
+
if used_non_trivial_size:
|
| 145 |
+
raise EinopsError("all bias dimensions should go after ellipsis in the output")
|
| 146 |
+
else:
|
| 147 |
+
# handles ellipsis correctly
|
| 148 |
+
for axis in axes:
|
| 149 |
+
if axis == _ellipsis:
|
| 150 |
+
if used_non_trivial_size:
|
| 151 |
+
raise EinopsError("all bias dimensions should go after ellipsis in the output")
|
| 152 |
+
elif axis in bias.identifiers:
|
| 153 |
+
_bias_shape.append(axes_lengths[axis])
|
| 154 |
+
used_non_trivial_size = True
|
| 155 |
+
else:
|
| 156 |
+
_bias_shape.append(1)
|
| 157 |
+
else:
|
| 158 |
+
_bias_shape = None
|
| 159 |
+
|
| 160 |
+
weight_bound = (3 / _fan_in) ** 0.5
|
| 161 |
+
bias_bound = (1 / _fan_in) ** 0.5
|
| 162 |
+
self._create_parameters(_weight_shape, weight_bound, _bias_shape, bias_bound)
|
| 163 |
+
|
| 164 |
+
# rewrite einsum expression with single-letter latin identifiers so that
|
| 165 |
+
# expression will be understood by any framework
|
| 166 |
+
mapped_identifiers = {*left.identifiers, *right.identifiers, *weight.identifiers}
|
| 167 |
+
if _ellipsis in mapped_identifiers:
|
| 168 |
+
mapped_identifiers.remove(_ellipsis)
|
| 169 |
+
mapped_identifiers = list(sorted(mapped_identifiers))
|
| 170 |
+
mapping2letters = {k: letter for letter, k in zip(string.ascii_lowercase, mapped_identifiers)}
|
| 171 |
+
mapping2letters[_ellipsis] = "..." # preserve ellipsis
|
| 172 |
+
|
| 173 |
+
def write_flat_remapped(axes: ParsedExpression):
|
| 174 |
+
result = []
|
| 175 |
+
for composed_axis in axes.composition:
|
| 176 |
+
if isinstance(composed_axis, list):
|
| 177 |
+
result.extend([mapping2letters[axis] for axis in composed_axis])
|
| 178 |
+
else:
|
| 179 |
+
assert composed_axis == _ellipsis
|
| 180 |
+
result.append("...")
|
| 181 |
+
return "".join(result)
|
| 182 |
+
|
| 183 |
+
self.einsum_pattern: str = "{},{}->{}".format(
|
| 184 |
+
write_flat_remapped(left),
|
| 185 |
+
write_flat_remapped(weight),
|
| 186 |
+
write_flat_remapped(right),
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
def _create_rearrange_layers(
|
| 190 |
+
self,
|
| 191 |
+
pre_reshape_pattern: Optional[str],
|
| 192 |
+
pre_reshape_lengths: Optional[Dict],
|
| 193 |
+
post_reshape_pattern: Optional[str],
|
| 194 |
+
post_reshape_lengths: Optional[Dict],
|
| 195 |
+
):
|
| 196 |
+
raise NotImplementedError("Should be defined in framework implementations")
|
| 197 |
+
|
| 198 |
+
def _create_parameters(self, weight_shape, weight_bound, bias_shape, bias_bound):
|
| 199 |
+
"""Shape and implementations"""
|
| 200 |
+
raise NotImplementedError("Should be defined in framework implementations")
|
| 201 |
+
|
| 202 |
+
def __repr__(self):
|
| 203 |
+
params = repr(self.pattern)
|
| 204 |
+
params += f", '{self.weight_shape}'"
|
| 205 |
+
if self.bias_shape is not None:
|
| 206 |
+
params += f", '{self.bias_shape}'"
|
| 207 |
+
for axis, length in self.axes_lengths.items():
|
| 208 |
+
params += ", {}={}".format(axis, length)
|
| 209 |
+
return "{}({})".format(self.__class__.__name__, params)
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
class _EinmixDebugger(_EinmixMixin):
|
| 213 |
+
"""Used only to test mixin"""
|
| 214 |
+
|
| 215 |
+
def _create_rearrange_layers(
|
| 216 |
+
self,
|
| 217 |
+
pre_reshape_pattern: Optional[str],
|
| 218 |
+
pre_reshape_lengths: Optional[Dict],
|
| 219 |
+
post_reshape_pattern: Optional[str],
|
| 220 |
+
post_reshape_lengths: Optional[Dict],
|
| 221 |
+
):
|
| 222 |
+
self.pre_reshape_pattern = pre_reshape_pattern
|
| 223 |
+
self.pre_reshape_lengths = pre_reshape_lengths
|
| 224 |
+
self.post_reshape_pattern = post_reshape_pattern
|
| 225 |
+
self.post_reshape_lengths = post_reshape_lengths
|
| 226 |
+
|
| 227 |
+
def _create_parameters(self, weight_shape, weight_bound, bias_shape, bias_bound):
|
| 228 |
+
self.saved_weight_shape = weight_shape
|
| 229 |
+
self.saved_bias_shape = bias_shape
|
tool_server/.venv/lib/python3.12/site-packages/einops/layers/flax.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dataclasses import field
|
| 2 |
+
from typing import Optional, Dict, cast
|
| 3 |
+
|
| 4 |
+
import flax.linen as nn
|
| 5 |
+
import jax
|
| 6 |
+
import jax.numpy as jnp
|
| 7 |
+
|
| 8 |
+
from . import RearrangeMixin, ReduceMixin
|
| 9 |
+
from ._einmix import _EinmixMixin
|
| 10 |
+
|
| 11 |
+
__author__ = "Alex Rogozhnikov"
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class Reduce(nn.Module):
|
| 15 |
+
pattern: str
|
| 16 |
+
reduction: str
|
| 17 |
+
sizes: dict = field(default_factory=lambda: {})
|
| 18 |
+
|
| 19 |
+
def setup(self):
|
| 20 |
+
self.reducer = ReduceMixin(self.pattern, self.reduction, **self.sizes)
|
| 21 |
+
|
| 22 |
+
def __call__(self, input):
|
| 23 |
+
return self.reducer._apply_recipe(input)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class Rearrange(nn.Module):
|
| 27 |
+
pattern: str
|
| 28 |
+
sizes: dict = field(default_factory=lambda: {})
|
| 29 |
+
|
| 30 |
+
def setup(self):
|
| 31 |
+
self.rearranger = RearrangeMixin(self.pattern, **self.sizes)
|
| 32 |
+
|
| 33 |
+
def __call__(self, input):
|
| 34 |
+
return self.rearranger._apply_recipe(input)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
class EinMix(nn.Module, _EinmixMixin):
|
| 38 |
+
pattern: str
|
| 39 |
+
weight_shape: str
|
| 40 |
+
bias_shape: Optional[str] = None
|
| 41 |
+
sizes: dict = field(default_factory=lambda: {})
|
| 42 |
+
|
| 43 |
+
def setup(self):
|
| 44 |
+
self.initialize_einmix(
|
| 45 |
+
pattern=self.pattern,
|
| 46 |
+
weight_shape=self.weight_shape,
|
| 47 |
+
bias_shape=self.bias_shape,
|
| 48 |
+
axes_lengths=self.sizes,
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
def _create_parameters(self, weight_shape, weight_bound, bias_shape, bias_bound):
|
| 52 |
+
self.weight = self.param("weight", jax.nn.initializers.uniform(weight_bound), weight_shape)
|
| 53 |
+
|
| 54 |
+
if bias_shape is not None:
|
| 55 |
+
self.bias = self.param("bias", jax.nn.initializers.uniform(bias_bound), bias_shape)
|
| 56 |
+
else:
|
| 57 |
+
self.bias = None
|
| 58 |
+
|
| 59 |
+
def _create_rearrange_layers(
|
| 60 |
+
self,
|
| 61 |
+
pre_reshape_pattern: Optional[str],
|
| 62 |
+
pre_reshape_lengths: Optional[Dict],
|
| 63 |
+
post_reshape_pattern: Optional[str],
|
| 64 |
+
post_reshape_lengths: Optional[Dict],
|
| 65 |
+
):
|
| 66 |
+
self.pre_rearrange = None
|
| 67 |
+
if pre_reshape_pattern is not None:
|
| 68 |
+
self.pre_rearrange = Rearrange(pre_reshape_pattern, sizes=cast(dict, pre_reshape_lengths))
|
| 69 |
+
|
| 70 |
+
self.post_rearrange = None
|
| 71 |
+
if post_reshape_pattern is not None:
|
| 72 |
+
self.post_rearrange = Rearrange(post_reshape_pattern, sizes=cast(dict, post_reshape_lengths))
|
| 73 |
+
|
| 74 |
+
def __call__(self, input):
|
| 75 |
+
if self.pre_rearrange is not None:
|
| 76 |
+
input = self.pre_rearrange(input)
|
| 77 |
+
result = jnp.einsum(self.einsum_pattern, input, self.weight)
|
| 78 |
+
if self.bias is not None:
|
| 79 |
+
result += self.bias
|
| 80 |
+
if self.post_rearrange is not None:
|
| 81 |
+
result = self.post_rearrange(result)
|
| 82 |
+
return result
|
tool_server/.venv/lib/python3.12/site-packages/einops/layers/keras.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__author__ = "Alex Rogozhnikov"
|
| 2 |
+
|
| 3 |
+
from ..layers.tensorflow import Rearrange, Reduce, EinMix
|
| 4 |
+
|
| 5 |
+
keras_custom_objects = {
|
| 6 |
+
Rearrange.__name__: Rearrange,
|
| 7 |
+
Reduce.__name__: Reduce,
|
| 8 |
+
EinMix.__name__: EinMix,
|
| 9 |
+
}
|
tool_server/.venv/lib/python3.12/site-packages/filelock-3.19.1.dist-info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This is free and unencumbered software released into the public domain.
|
| 2 |
+
|
| 3 |
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
| 4 |
+
distribute this software, either in source code form or as a compiled
|
| 5 |
+
binary, for any purpose, commercial or non-commercial, and by any
|
| 6 |
+
means.
|
| 7 |
+
|
| 8 |
+
In jurisdictions that recognize copyright laws, the author or authors
|
| 9 |
+
of this software dedicate any and all copyright interest in the
|
| 10 |
+
software to the public domain. We make this dedication for the benefit
|
| 11 |
+
of the public at large and to the detriment of our heirs and
|
| 12 |
+
successors. We intend this dedication to be an overt act of
|
| 13 |
+
relinquishment in perpetuity of all present and future rights to this
|
| 14 |
+
software under copyright law.
|
| 15 |
+
|
| 16 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 17 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 18 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
| 19 |
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
| 20 |
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
| 21 |
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 22 |
+
OTHER DEALINGS IN THE SOFTWARE.
|
| 23 |
+
|
| 24 |
+
For more information, please refer to <http://unlicense.org>
|
tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (1.57 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/_api.cpython-312.pyc
ADDED
|
Binary file (16.6 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/_error.cpython-312.pyc
ADDED
|
Binary file (1.75 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/_soft.cpython-312.pyc
ADDED
|
Binary file (2.46 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/_unix.cpython-312.pyc
ADDED
|
Binary file (3.54 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/_util.cpython-312.pyc
ADDED
|
Binary file (2 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/_windows.cpython-312.pyc
ADDED
|
Binary file (3.26 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/asyncio.cpython-312.pyc
ADDED
|
Binary file (15.6 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/filelock/__pycache__/version.cpython-312.pyc
ADDED
|
Binary file (639 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/frozenlist-1.7.0.dist-info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright 2013-2019 Nikolay Kim and Andrew Svetlov
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
tool_server/.venv/lib/python3.12/site-packages/frozenlist/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (4.06 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec-2025.9.0.dist-info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
BSD 3-Clause License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2018, Martin Durant
|
| 4 |
+
All rights reserved.
|
| 5 |
+
|
| 6 |
+
Redistribution and use in source and binary forms, with or without
|
| 7 |
+
modification, are permitted provided that the following conditions are met:
|
| 8 |
+
|
| 9 |
+
* Redistributions of source code must retain the above copyright notice, this
|
| 10 |
+
list of conditions and the following disclaimer.
|
| 11 |
+
|
| 12 |
+
* Redistributions in binary form must reproduce the above copyright notice,
|
| 13 |
+
this list of conditions and the following disclaimer in the documentation
|
| 14 |
+
and/or other materials provided with the distribution.
|
| 15 |
+
|
| 16 |
+
* Neither the name of the copyright holder nor the names of its
|
| 17 |
+
contributors may be used to endorse or promote products derived from
|
| 18 |
+
this software without specific prior written permission.
|
| 19 |
+
|
| 20 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
| 21 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 22 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 23 |
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
| 24 |
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 25 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 26 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 27 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
| 28 |
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 29 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/gist.cpython-312.pyc
ADDED
|
Binary file (9.6 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/git.cpython-312.pyc
ADDED
|
Binary file (5.91 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/github.cpython-312.pyc
ADDED
|
Binary file (14.5 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/http.cpython-312.pyc
ADDED
|
Binary file (42.4 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/http_sync.cpython-312.pyc
ADDED
|
Binary file (40 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/jupyter.cpython-312.pyc
ADDED
|
Binary file (6.47 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/libarchive.cpython-312.pyc
ADDED
|
Binary file (8.7 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/local.cpython-312.pyc
ADDED
|
Binary file (25.6 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/memory.cpython-312.pyc
ADDED
|
Binary file (14.3 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/reference.cpython-312.pyc
ADDED
|
Binary file (64.7 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/sftp.cpython-312.pyc
ADDED
|
Binary file (9.75 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/smb.cpython-312.pyc
ADDED
|
Binary file (19.2 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/tar.cpython-312.pyc
ADDED
|
Binary file (4.68 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/webhdfs.cpython-312.pyc
ADDED
|
Binary file (22.9 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/implementations/__pycache__/zip.cpython-312.pyc
ADDED
|
Binary file (8.29 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__init__.py
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from hashlib import md5
|
| 3 |
+
|
| 4 |
+
import pytest
|
| 5 |
+
|
| 6 |
+
from fsspec.implementations.local import LocalFileSystem
|
| 7 |
+
from fsspec.tests.abstract.copy import AbstractCopyTests # noqa: F401
|
| 8 |
+
from fsspec.tests.abstract.get import AbstractGetTests # noqa: F401
|
| 9 |
+
from fsspec.tests.abstract.open import AbstractOpenTests # noqa: F401
|
| 10 |
+
from fsspec.tests.abstract.pipe import AbstractPipeTests # noqa: F401
|
| 11 |
+
from fsspec.tests.abstract.put import AbstractPutTests # noqa: F401
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class BaseAbstractFixtures:
|
| 15 |
+
"""
|
| 16 |
+
Abstract base class containing fixtures that are used by but never need to
|
| 17 |
+
be overridden in derived filesystem-specific classes to run the abstract
|
| 18 |
+
tests on such filesystems.
|
| 19 |
+
"""
|
| 20 |
+
|
| 21 |
+
@pytest.fixture
|
| 22 |
+
def fs_bulk_operations_scenario_0(self, fs, fs_join, fs_path):
|
| 23 |
+
"""
|
| 24 |
+
Scenario on remote filesystem that is used for many cp/get/put tests.
|
| 25 |
+
|
| 26 |
+
Cleans up at the end of each test it which it is used.
|
| 27 |
+
"""
|
| 28 |
+
source = self._bulk_operations_scenario_0(fs, fs_join, fs_path)
|
| 29 |
+
yield source
|
| 30 |
+
fs.rm(source, recursive=True)
|
| 31 |
+
|
| 32 |
+
@pytest.fixture
|
| 33 |
+
def fs_glob_edge_cases_files(self, fs, fs_join, fs_path):
|
| 34 |
+
"""
|
| 35 |
+
Scenario on remote filesystem that is used for glob edge cases cp/get/put tests.
|
| 36 |
+
|
| 37 |
+
Cleans up at the end of each test it which it is used.
|
| 38 |
+
"""
|
| 39 |
+
source = self._glob_edge_cases_files(fs, fs_join, fs_path)
|
| 40 |
+
yield source
|
| 41 |
+
fs.rm(source, recursive=True)
|
| 42 |
+
|
| 43 |
+
@pytest.fixture
|
| 44 |
+
def fs_dir_and_file_with_same_name_prefix(self, fs, fs_join, fs_path):
|
| 45 |
+
"""
|
| 46 |
+
Scenario on remote filesystem that is used to check cp/get/put on directory
|
| 47 |
+
and file with the same name prefixes.
|
| 48 |
+
|
| 49 |
+
Cleans up at the end of each test it which it is used.
|
| 50 |
+
"""
|
| 51 |
+
source = self._dir_and_file_with_same_name_prefix(fs, fs_join, fs_path)
|
| 52 |
+
yield source
|
| 53 |
+
fs.rm(source, recursive=True)
|
| 54 |
+
|
| 55 |
+
@pytest.fixture
|
| 56 |
+
def fs_10_files_with_hashed_names(self, fs, fs_join, fs_path):
|
| 57 |
+
"""
|
| 58 |
+
Scenario on remote filesystem that is used to check cp/get/put files order
|
| 59 |
+
when source and destination are lists.
|
| 60 |
+
|
| 61 |
+
Cleans up at the end of each test it which it is used.
|
| 62 |
+
"""
|
| 63 |
+
source = self._10_files_with_hashed_names(fs, fs_join, fs_path)
|
| 64 |
+
yield source
|
| 65 |
+
fs.rm(source, recursive=True)
|
| 66 |
+
|
| 67 |
+
@pytest.fixture
|
| 68 |
+
def fs_target(self, fs, fs_join, fs_path):
|
| 69 |
+
"""
|
| 70 |
+
Return name of remote directory that does not yet exist to copy into.
|
| 71 |
+
|
| 72 |
+
Cleans up at the end of each test it which it is used.
|
| 73 |
+
"""
|
| 74 |
+
target = fs_join(fs_path, "target")
|
| 75 |
+
yield target
|
| 76 |
+
if fs.exists(target):
|
| 77 |
+
fs.rm(target, recursive=True)
|
| 78 |
+
|
| 79 |
+
@pytest.fixture
|
| 80 |
+
def local_bulk_operations_scenario_0(self, local_fs, local_join, local_path):
|
| 81 |
+
"""
|
| 82 |
+
Scenario on local filesystem that is used for many cp/get/put tests.
|
| 83 |
+
|
| 84 |
+
Cleans up at the end of each test it which it is used.
|
| 85 |
+
"""
|
| 86 |
+
source = self._bulk_operations_scenario_0(local_fs, local_join, local_path)
|
| 87 |
+
yield source
|
| 88 |
+
local_fs.rm(source, recursive=True)
|
| 89 |
+
|
| 90 |
+
@pytest.fixture
|
| 91 |
+
def local_glob_edge_cases_files(self, local_fs, local_join, local_path):
|
| 92 |
+
"""
|
| 93 |
+
Scenario on local filesystem that is used for glob edge cases cp/get/put tests.
|
| 94 |
+
|
| 95 |
+
Cleans up at the end of each test it which it is used.
|
| 96 |
+
"""
|
| 97 |
+
source = self._glob_edge_cases_files(local_fs, local_join, local_path)
|
| 98 |
+
yield source
|
| 99 |
+
local_fs.rm(source, recursive=True)
|
| 100 |
+
|
| 101 |
+
@pytest.fixture
|
| 102 |
+
def local_dir_and_file_with_same_name_prefix(
|
| 103 |
+
self, local_fs, local_join, local_path
|
| 104 |
+
):
|
| 105 |
+
"""
|
| 106 |
+
Scenario on local filesystem that is used to check cp/get/put on directory
|
| 107 |
+
and file with the same name prefixes.
|
| 108 |
+
|
| 109 |
+
Cleans up at the end of each test it which it is used.
|
| 110 |
+
"""
|
| 111 |
+
source = self._dir_and_file_with_same_name_prefix(
|
| 112 |
+
local_fs, local_join, local_path
|
| 113 |
+
)
|
| 114 |
+
yield source
|
| 115 |
+
local_fs.rm(source, recursive=True)
|
| 116 |
+
|
| 117 |
+
@pytest.fixture
|
| 118 |
+
def local_10_files_with_hashed_names(self, local_fs, local_join, local_path):
|
| 119 |
+
"""
|
| 120 |
+
Scenario on local filesystem that is used to check cp/get/put files order
|
| 121 |
+
when source and destination are lists.
|
| 122 |
+
|
| 123 |
+
Cleans up at the end of each test it which it is used.
|
| 124 |
+
"""
|
| 125 |
+
source = self._10_files_with_hashed_names(local_fs, local_join, local_path)
|
| 126 |
+
yield source
|
| 127 |
+
local_fs.rm(source, recursive=True)
|
| 128 |
+
|
| 129 |
+
@pytest.fixture
|
| 130 |
+
def local_target(self, local_fs, local_join, local_path):
|
| 131 |
+
"""
|
| 132 |
+
Return name of local directory that does not yet exist to copy into.
|
| 133 |
+
|
| 134 |
+
Cleans up at the end of each test it which it is used.
|
| 135 |
+
"""
|
| 136 |
+
target = local_join(local_path, "target")
|
| 137 |
+
yield target
|
| 138 |
+
if local_fs.exists(target):
|
| 139 |
+
local_fs.rm(target, recursive=True)
|
| 140 |
+
|
| 141 |
+
def _glob_edge_cases_files(self, some_fs, some_join, some_path):
|
| 142 |
+
"""
|
| 143 |
+
Scenario that is used for glob edge cases cp/get/put tests.
|
| 144 |
+
Creates the following directory and file structure:
|
| 145 |
+
|
| 146 |
+
📁 source
|
| 147 |
+
├── 📄 file1
|
| 148 |
+
├── 📄 file2
|
| 149 |
+
├── 📁 subdir0
|
| 150 |
+
│ ├── 📄 subfile1
|
| 151 |
+
│ ├── 📄 subfile2
|
| 152 |
+
│ └── 📁 nesteddir
|
| 153 |
+
│ └── 📄 nestedfile
|
| 154 |
+
└── 📁 subdir1
|
| 155 |
+
├── 📄 subfile1
|
| 156 |
+
├── 📄 subfile2
|
| 157 |
+
└── 📁 nesteddir
|
| 158 |
+
└── 📄 nestedfile
|
| 159 |
+
"""
|
| 160 |
+
source = some_join(some_path, "source")
|
| 161 |
+
some_fs.touch(some_join(source, "file1"))
|
| 162 |
+
some_fs.touch(some_join(source, "file2"))
|
| 163 |
+
|
| 164 |
+
for subdir_idx in range(2):
|
| 165 |
+
subdir = some_join(source, f"subdir{subdir_idx}")
|
| 166 |
+
nesteddir = some_join(subdir, "nesteddir")
|
| 167 |
+
some_fs.makedirs(nesteddir)
|
| 168 |
+
some_fs.touch(some_join(subdir, "subfile1"))
|
| 169 |
+
some_fs.touch(some_join(subdir, "subfile2"))
|
| 170 |
+
some_fs.touch(some_join(nesteddir, "nestedfile"))
|
| 171 |
+
|
| 172 |
+
return source
|
| 173 |
+
|
| 174 |
+
def _bulk_operations_scenario_0(self, some_fs, some_join, some_path):
|
| 175 |
+
"""
|
| 176 |
+
Scenario that is used for many cp/get/put tests. Creates the following
|
| 177 |
+
directory and file structure:
|
| 178 |
+
|
| 179 |
+
📁 source
|
| 180 |
+
├── 📄 file1
|
| 181 |
+
├── 📄 file2
|
| 182 |
+
└── 📁 subdir
|
| 183 |
+
├── 📄 subfile1
|
| 184 |
+
├── 📄 subfile2
|
| 185 |
+
└── 📁 nesteddir
|
| 186 |
+
└── 📄 nestedfile
|
| 187 |
+
"""
|
| 188 |
+
source = some_join(some_path, "source")
|
| 189 |
+
subdir = some_join(source, "subdir")
|
| 190 |
+
nesteddir = some_join(subdir, "nesteddir")
|
| 191 |
+
some_fs.makedirs(nesteddir)
|
| 192 |
+
some_fs.touch(some_join(source, "file1"))
|
| 193 |
+
some_fs.touch(some_join(source, "file2"))
|
| 194 |
+
some_fs.touch(some_join(subdir, "subfile1"))
|
| 195 |
+
some_fs.touch(some_join(subdir, "subfile2"))
|
| 196 |
+
some_fs.touch(some_join(nesteddir, "nestedfile"))
|
| 197 |
+
return source
|
| 198 |
+
|
| 199 |
+
def _dir_and_file_with_same_name_prefix(self, some_fs, some_join, some_path):
|
| 200 |
+
"""
|
| 201 |
+
Scenario that is used to check cp/get/put on directory and file with
|
| 202 |
+
the same name prefixes. Creates the following directory and file structure:
|
| 203 |
+
|
| 204 |
+
📁 source
|
| 205 |
+
├── 📄 subdir.txt
|
| 206 |
+
└── 📁 subdir
|
| 207 |
+
└── 📄 subfile.txt
|
| 208 |
+
"""
|
| 209 |
+
source = some_join(some_path, "source")
|
| 210 |
+
subdir = some_join(source, "subdir")
|
| 211 |
+
file = some_join(source, "subdir.txt")
|
| 212 |
+
subfile = some_join(subdir, "subfile.txt")
|
| 213 |
+
some_fs.makedirs(subdir)
|
| 214 |
+
some_fs.touch(file)
|
| 215 |
+
some_fs.touch(subfile)
|
| 216 |
+
return source
|
| 217 |
+
|
| 218 |
+
def _10_files_with_hashed_names(self, some_fs, some_join, some_path):
|
| 219 |
+
"""
|
| 220 |
+
Scenario that is used to check cp/get/put files order when source and
|
| 221 |
+
destination are lists. Creates the following directory and file structure:
|
| 222 |
+
|
| 223 |
+
📁 source
|
| 224 |
+
└── 📄 {hashed([0-9])}.txt
|
| 225 |
+
"""
|
| 226 |
+
source = some_join(some_path, "source")
|
| 227 |
+
for i in range(10):
|
| 228 |
+
hashed_i = md5(str(i).encode("utf-8")).hexdigest()
|
| 229 |
+
path = some_join(source, f"{hashed_i}.txt")
|
| 230 |
+
some_fs.pipe(path=path, value=f"{i}".encode())
|
| 231 |
+
return source
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
class AbstractFixtures(BaseAbstractFixtures):
|
| 235 |
+
"""
|
| 236 |
+
Abstract base class containing fixtures that may be overridden in derived
|
| 237 |
+
filesystem-specific classes to run the abstract tests on such filesystems.
|
| 238 |
+
|
| 239 |
+
For any particular filesystem some of these fixtures must be overridden,
|
| 240 |
+
such as ``fs`` and ``fs_path``, and others may be overridden if the
|
| 241 |
+
default functions here are not appropriate, such as ``fs_join``.
|
| 242 |
+
"""
|
| 243 |
+
|
| 244 |
+
@pytest.fixture
|
| 245 |
+
def fs(self):
|
| 246 |
+
raise NotImplementedError("This function must be overridden in derived classes")
|
| 247 |
+
|
| 248 |
+
@pytest.fixture
|
| 249 |
+
def fs_join(self):
|
| 250 |
+
"""
|
| 251 |
+
Return a function that joins its arguments together into a path.
|
| 252 |
+
|
| 253 |
+
Most fsspec implementations join paths in a platform-dependent way,
|
| 254 |
+
but some will override this to always use a forward slash.
|
| 255 |
+
"""
|
| 256 |
+
return os.path.join
|
| 257 |
+
|
| 258 |
+
@pytest.fixture
|
| 259 |
+
def fs_path(self):
|
| 260 |
+
raise NotImplementedError("This function must be overridden in derived classes")
|
| 261 |
+
|
| 262 |
+
@pytest.fixture(scope="class")
|
| 263 |
+
def local_fs(self):
|
| 264 |
+
# Maybe need an option for auto_mkdir=False? This is only relevant
|
| 265 |
+
# for certain implementations.
|
| 266 |
+
return LocalFileSystem(auto_mkdir=True)
|
| 267 |
+
|
| 268 |
+
@pytest.fixture
|
| 269 |
+
def local_join(self):
|
| 270 |
+
"""
|
| 271 |
+
Return a function that joins its arguments together into a path, on
|
| 272 |
+
the local filesystem.
|
| 273 |
+
"""
|
| 274 |
+
return os.path.join
|
| 275 |
+
|
| 276 |
+
@pytest.fixture
|
| 277 |
+
def local_path(self, tmpdir):
|
| 278 |
+
return tmpdir
|
| 279 |
+
|
| 280 |
+
@pytest.fixture
|
| 281 |
+
def supports_empty_directories(self):
|
| 282 |
+
"""
|
| 283 |
+
Return whether this implementation supports empty directories.
|
| 284 |
+
"""
|
| 285 |
+
return True
|
| 286 |
+
|
| 287 |
+
@pytest.fixture
|
| 288 |
+
def fs_sanitize_path(self):
|
| 289 |
+
return lambda x: x
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (13.9 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/common.cpython-312.pyc
ADDED
|
Binary file (2.14 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/copy.cpython-312.pyc
ADDED
|
Binary file (21 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/get.cpython-312.pyc
ADDED
|
Binary file (20.9 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/mv.cpython-312.pyc
ADDED
|
Binary file (2.54 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/open.cpython-312.pyc
ADDED
|
Binary file (1.18 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/pipe.cpython-312.pyc
ADDED
|
Binary file (1.09 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/__pycache__/put.cpython-312.pyc
ADDED
|
Binary file (22 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/common.py
ADDED
|
@@ -0,0 +1,175 @@
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
GLOB_EDGE_CASES_TESTS = {
|
| 2 |
+
"argnames": ("path", "recursive", "maxdepth", "expected"),
|
| 3 |
+
"argvalues": [
|
| 4 |
+
("fil?1", False, None, ["file1"]),
|
| 5 |
+
("fil?1", True, None, ["file1"]),
|
| 6 |
+
("file[1-2]", False, None, ["file1", "file2"]),
|
| 7 |
+
("file[1-2]", True, None, ["file1", "file2"]),
|
| 8 |
+
("*", False, None, ["file1", "file2"]),
|
| 9 |
+
(
|
| 10 |
+
"*",
|
| 11 |
+
True,
|
| 12 |
+
None,
|
| 13 |
+
[
|
| 14 |
+
"file1",
|
| 15 |
+
"file2",
|
| 16 |
+
"subdir0/subfile1",
|
| 17 |
+
"subdir0/subfile2",
|
| 18 |
+
"subdir0/nesteddir/nestedfile",
|
| 19 |
+
"subdir1/subfile1",
|
| 20 |
+
"subdir1/subfile2",
|
| 21 |
+
"subdir1/nesteddir/nestedfile",
|
| 22 |
+
],
|
| 23 |
+
),
|
| 24 |
+
("*", True, 1, ["file1", "file2"]),
|
| 25 |
+
(
|
| 26 |
+
"*",
|
| 27 |
+
True,
|
| 28 |
+
2,
|
| 29 |
+
[
|
| 30 |
+
"file1",
|
| 31 |
+
"file2",
|
| 32 |
+
"subdir0/subfile1",
|
| 33 |
+
"subdir0/subfile2",
|
| 34 |
+
"subdir1/subfile1",
|
| 35 |
+
"subdir1/subfile2",
|
| 36 |
+
],
|
| 37 |
+
),
|
| 38 |
+
("*1", False, None, ["file1"]),
|
| 39 |
+
(
|
| 40 |
+
"*1",
|
| 41 |
+
True,
|
| 42 |
+
None,
|
| 43 |
+
[
|
| 44 |
+
"file1",
|
| 45 |
+
"subdir1/subfile1",
|
| 46 |
+
"subdir1/subfile2",
|
| 47 |
+
"subdir1/nesteddir/nestedfile",
|
| 48 |
+
],
|
| 49 |
+
),
|
| 50 |
+
("*1", True, 2, ["file1", "subdir1/subfile1", "subdir1/subfile2"]),
|
| 51 |
+
(
|
| 52 |
+
"**",
|
| 53 |
+
False,
|
| 54 |
+
None,
|
| 55 |
+
[
|
| 56 |
+
"file1",
|
| 57 |
+
"file2",
|
| 58 |
+
"subdir0/subfile1",
|
| 59 |
+
"subdir0/subfile2",
|
| 60 |
+
"subdir0/nesteddir/nestedfile",
|
| 61 |
+
"subdir1/subfile1",
|
| 62 |
+
"subdir1/subfile2",
|
| 63 |
+
"subdir1/nesteddir/nestedfile",
|
| 64 |
+
],
|
| 65 |
+
),
|
| 66 |
+
(
|
| 67 |
+
"**",
|
| 68 |
+
True,
|
| 69 |
+
None,
|
| 70 |
+
[
|
| 71 |
+
"file1",
|
| 72 |
+
"file2",
|
| 73 |
+
"subdir0/subfile1",
|
| 74 |
+
"subdir0/subfile2",
|
| 75 |
+
"subdir0/nesteddir/nestedfile",
|
| 76 |
+
"subdir1/subfile1",
|
| 77 |
+
"subdir1/subfile2",
|
| 78 |
+
"subdir1/nesteddir/nestedfile",
|
| 79 |
+
],
|
| 80 |
+
),
|
| 81 |
+
("**", True, 1, ["file1", "file2"]),
|
| 82 |
+
(
|
| 83 |
+
"**",
|
| 84 |
+
True,
|
| 85 |
+
2,
|
| 86 |
+
[
|
| 87 |
+
"file1",
|
| 88 |
+
"file2",
|
| 89 |
+
"subdir0/subfile1",
|
| 90 |
+
"subdir0/subfile2",
|
| 91 |
+
"subdir0/nesteddir/nestedfile",
|
| 92 |
+
"subdir1/subfile1",
|
| 93 |
+
"subdir1/subfile2",
|
| 94 |
+
"subdir1/nesteddir/nestedfile",
|
| 95 |
+
],
|
| 96 |
+
),
|
| 97 |
+
(
|
| 98 |
+
"**",
|
| 99 |
+
False,
|
| 100 |
+
2,
|
| 101 |
+
[
|
| 102 |
+
"file1",
|
| 103 |
+
"file2",
|
| 104 |
+
"subdir0/subfile1",
|
| 105 |
+
"subdir0/subfile2",
|
| 106 |
+
"subdir1/subfile1",
|
| 107 |
+
"subdir1/subfile2",
|
| 108 |
+
],
|
| 109 |
+
),
|
| 110 |
+
("**/*1", False, None, ["file1", "subdir0/subfile1", "subdir1/subfile1"]),
|
| 111 |
+
(
|
| 112 |
+
"**/*1",
|
| 113 |
+
True,
|
| 114 |
+
None,
|
| 115 |
+
[
|
| 116 |
+
"file1",
|
| 117 |
+
"subdir0/subfile1",
|
| 118 |
+
"subdir1/subfile1",
|
| 119 |
+
"subdir1/subfile2",
|
| 120 |
+
"subdir1/nesteddir/nestedfile",
|
| 121 |
+
],
|
| 122 |
+
),
|
| 123 |
+
("**/*1", True, 1, ["file1"]),
|
| 124 |
+
(
|
| 125 |
+
"**/*1",
|
| 126 |
+
True,
|
| 127 |
+
2,
|
| 128 |
+
["file1", "subdir0/subfile1", "subdir1/subfile1", "subdir1/subfile2"],
|
| 129 |
+
),
|
| 130 |
+
("**/*1", False, 2, ["file1", "subdir0/subfile1", "subdir1/subfile1"]),
|
| 131 |
+
("**/subdir0", False, None, []),
|
| 132 |
+
("**/subdir0", True, None, ["subfile1", "subfile2", "nesteddir/nestedfile"]),
|
| 133 |
+
("**/subdir0/nested*", False, 2, []),
|
| 134 |
+
("**/subdir0/nested*", True, 2, ["nestedfile"]),
|
| 135 |
+
("subdir[1-2]", False, None, []),
|
| 136 |
+
("subdir[1-2]", True, None, ["subfile1", "subfile2", "nesteddir/nestedfile"]),
|
| 137 |
+
("subdir[1-2]", True, 2, ["subfile1", "subfile2"]),
|
| 138 |
+
("subdir[0-1]", False, None, []),
|
| 139 |
+
(
|
| 140 |
+
"subdir[0-1]",
|
| 141 |
+
True,
|
| 142 |
+
None,
|
| 143 |
+
[
|
| 144 |
+
"subdir0/subfile1",
|
| 145 |
+
"subdir0/subfile2",
|
| 146 |
+
"subdir0/nesteddir/nestedfile",
|
| 147 |
+
"subdir1/subfile1",
|
| 148 |
+
"subdir1/subfile2",
|
| 149 |
+
"subdir1/nesteddir/nestedfile",
|
| 150 |
+
],
|
| 151 |
+
),
|
| 152 |
+
(
|
| 153 |
+
"subdir[0-1]/*fil[e]*",
|
| 154 |
+
False,
|
| 155 |
+
None,
|
| 156 |
+
[
|
| 157 |
+
"subdir0/subfile1",
|
| 158 |
+
"subdir0/subfile2",
|
| 159 |
+
"subdir1/subfile1",
|
| 160 |
+
"subdir1/subfile2",
|
| 161 |
+
],
|
| 162 |
+
),
|
| 163 |
+
(
|
| 164 |
+
"subdir[0-1]/*fil[e]*",
|
| 165 |
+
True,
|
| 166 |
+
None,
|
| 167 |
+
[
|
| 168 |
+
"subdir0/subfile1",
|
| 169 |
+
"subdir0/subfile2",
|
| 170 |
+
"subdir1/subfile1",
|
| 171 |
+
"subdir1/subfile2",
|
| 172 |
+
],
|
| 173 |
+
),
|
| 174 |
+
],
|
| 175 |
+
}
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/copy.py
ADDED
|
@@ -0,0 +1,557 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from hashlib import md5
|
| 2 |
+
from itertools import product
|
| 3 |
+
|
| 4 |
+
import pytest
|
| 5 |
+
|
| 6 |
+
from fsspec.tests.abstract.common import GLOB_EDGE_CASES_TESTS
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class AbstractCopyTests:
|
| 10 |
+
def test_copy_file_to_existing_directory(
|
| 11 |
+
self,
|
| 12 |
+
fs,
|
| 13 |
+
fs_join,
|
| 14 |
+
fs_bulk_operations_scenario_0,
|
| 15 |
+
fs_target,
|
| 16 |
+
supports_empty_directories,
|
| 17 |
+
):
|
| 18 |
+
# Copy scenario 1a
|
| 19 |
+
source = fs_bulk_operations_scenario_0
|
| 20 |
+
|
| 21 |
+
target = fs_target
|
| 22 |
+
fs.mkdir(target)
|
| 23 |
+
if not supports_empty_directories:
|
| 24 |
+
# Force target directory to exist by adding a dummy file
|
| 25 |
+
fs.touch(fs_join(target, "dummy"))
|
| 26 |
+
assert fs.isdir(target)
|
| 27 |
+
|
| 28 |
+
target_file2 = fs_join(target, "file2")
|
| 29 |
+
target_subfile1 = fs_join(target, "subfile1")
|
| 30 |
+
|
| 31 |
+
# Copy from source directory
|
| 32 |
+
fs.cp(fs_join(source, "file2"), target)
|
| 33 |
+
assert fs.isfile(target_file2)
|
| 34 |
+
|
| 35 |
+
# Copy from sub directory
|
| 36 |
+
fs.cp(fs_join(source, "subdir", "subfile1"), target)
|
| 37 |
+
assert fs.isfile(target_subfile1)
|
| 38 |
+
|
| 39 |
+
# Remove copied files
|
| 40 |
+
fs.rm([target_file2, target_subfile1])
|
| 41 |
+
assert not fs.exists(target_file2)
|
| 42 |
+
assert not fs.exists(target_subfile1)
|
| 43 |
+
|
| 44 |
+
# Repeat with trailing slash on target
|
| 45 |
+
fs.cp(fs_join(source, "file2"), target + "/")
|
| 46 |
+
assert fs.isdir(target)
|
| 47 |
+
assert fs.isfile(target_file2)
|
| 48 |
+
|
| 49 |
+
fs.cp(fs_join(source, "subdir", "subfile1"), target + "/")
|
| 50 |
+
assert fs.isfile(target_subfile1)
|
| 51 |
+
|
| 52 |
+
def test_copy_file_to_new_directory(
|
| 53 |
+
self, fs, fs_join, fs_bulk_operations_scenario_0, fs_target
|
| 54 |
+
):
|
| 55 |
+
# Copy scenario 1b
|
| 56 |
+
source = fs_bulk_operations_scenario_0
|
| 57 |
+
|
| 58 |
+
target = fs_target
|
| 59 |
+
fs.mkdir(target)
|
| 60 |
+
|
| 61 |
+
fs.cp(
|
| 62 |
+
fs_join(source, "subdir", "subfile1"), fs_join(target, "newdir/")
|
| 63 |
+
) # Note trailing slash
|
| 64 |
+
assert fs.isdir(target)
|
| 65 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 66 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile1"))
|
| 67 |
+
|
| 68 |
+
def test_copy_file_to_file_in_existing_directory(
|
| 69 |
+
self,
|
| 70 |
+
fs,
|
| 71 |
+
fs_join,
|
| 72 |
+
fs_bulk_operations_scenario_0,
|
| 73 |
+
fs_target,
|
| 74 |
+
supports_empty_directories,
|
| 75 |
+
):
|
| 76 |
+
# Copy scenario 1c
|
| 77 |
+
source = fs_bulk_operations_scenario_0
|
| 78 |
+
|
| 79 |
+
target = fs_target
|
| 80 |
+
fs.mkdir(target)
|
| 81 |
+
if not supports_empty_directories:
|
| 82 |
+
# Force target directory to exist by adding a dummy file
|
| 83 |
+
fs.touch(fs_join(target, "dummy"))
|
| 84 |
+
assert fs.isdir(target)
|
| 85 |
+
|
| 86 |
+
fs.cp(fs_join(source, "subdir", "subfile1"), fs_join(target, "newfile"))
|
| 87 |
+
assert fs.isfile(fs_join(target, "newfile"))
|
| 88 |
+
|
| 89 |
+
def test_copy_file_to_file_in_new_directory(
|
| 90 |
+
self, fs, fs_join, fs_bulk_operations_scenario_0, fs_target
|
| 91 |
+
):
|
| 92 |
+
# Copy scenario 1d
|
| 93 |
+
source = fs_bulk_operations_scenario_0
|
| 94 |
+
|
| 95 |
+
target = fs_target
|
| 96 |
+
fs.mkdir(target)
|
| 97 |
+
|
| 98 |
+
fs.cp(
|
| 99 |
+
fs_join(source, "subdir", "subfile1"), fs_join(target, "newdir", "newfile")
|
| 100 |
+
)
|
| 101 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 102 |
+
assert fs.isfile(fs_join(target, "newdir", "newfile"))
|
| 103 |
+
|
| 104 |
+
def test_copy_directory_to_existing_directory(
|
| 105 |
+
self,
|
| 106 |
+
fs,
|
| 107 |
+
fs_join,
|
| 108 |
+
fs_bulk_operations_scenario_0,
|
| 109 |
+
fs_target,
|
| 110 |
+
supports_empty_directories,
|
| 111 |
+
):
|
| 112 |
+
# Copy scenario 1e
|
| 113 |
+
source = fs_bulk_operations_scenario_0
|
| 114 |
+
|
| 115 |
+
target = fs_target
|
| 116 |
+
fs.mkdir(target)
|
| 117 |
+
if not supports_empty_directories:
|
| 118 |
+
# Force target directory to exist by adding a dummy file
|
| 119 |
+
dummy = fs_join(target, "dummy")
|
| 120 |
+
fs.touch(dummy)
|
| 121 |
+
assert fs.isdir(target)
|
| 122 |
+
|
| 123 |
+
for source_slash, target_slash in zip([False, True], [False, True]):
|
| 124 |
+
s = fs_join(source, "subdir")
|
| 125 |
+
if source_slash:
|
| 126 |
+
s += "/"
|
| 127 |
+
t = target + "/" if target_slash else target
|
| 128 |
+
|
| 129 |
+
# Without recursive does nothing
|
| 130 |
+
fs.cp(s, t)
|
| 131 |
+
assert fs.ls(target, detail=False) == (
|
| 132 |
+
[] if supports_empty_directories else [dummy]
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
# With recursive
|
| 136 |
+
fs.cp(s, t, recursive=True)
|
| 137 |
+
if source_slash:
|
| 138 |
+
assert fs.isfile(fs_join(target, "subfile1"))
|
| 139 |
+
assert fs.isfile(fs_join(target, "subfile2"))
|
| 140 |
+
assert fs.isdir(fs_join(target, "nesteddir"))
|
| 141 |
+
assert fs.isfile(fs_join(target, "nesteddir", "nestedfile"))
|
| 142 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 143 |
+
|
| 144 |
+
fs.rm(
|
| 145 |
+
[
|
| 146 |
+
fs_join(target, "subfile1"),
|
| 147 |
+
fs_join(target, "subfile2"),
|
| 148 |
+
fs_join(target, "nesteddir"),
|
| 149 |
+
],
|
| 150 |
+
recursive=True,
|
| 151 |
+
)
|
| 152 |
+
else:
|
| 153 |
+
assert fs.isdir(fs_join(target, "subdir"))
|
| 154 |
+
assert fs.isfile(fs_join(target, "subdir", "subfile1"))
|
| 155 |
+
assert fs.isfile(fs_join(target, "subdir", "subfile2"))
|
| 156 |
+
assert fs.isdir(fs_join(target, "subdir", "nesteddir"))
|
| 157 |
+
assert fs.isfile(fs_join(target, "subdir", "nesteddir", "nestedfile"))
|
| 158 |
+
|
| 159 |
+
fs.rm(fs_join(target, "subdir"), recursive=True)
|
| 160 |
+
assert fs.ls(target, detail=False) == (
|
| 161 |
+
[] if supports_empty_directories else [dummy]
|
| 162 |
+
)
|
| 163 |
+
|
| 164 |
+
# Limit recursive by maxdepth
|
| 165 |
+
fs.cp(s, t, recursive=True, maxdepth=1)
|
| 166 |
+
if source_slash:
|
| 167 |
+
assert fs.isfile(fs_join(target, "subfile1"))
|
| 168 |
+
assert fs.isfile(fs_join(target, "subfile2"))
|
| 169 |
+
assert not fs.exists(fs_join(target, "nesteddir"))
|
| 170 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 171 |
+
|
| 172 |
+
fs.rm(
|
| 173 |
+
[
|
| 174 |
+
fs_join(target, "subfile1"),
|
| 175 |
+
fs_join(target, "subfile2"),
|
| 176 |
+
],
|
| 177 |
+
recursive=True,
|
| 178 |
+
)
|
| 179 |
+
else:
|
| 180 |
+
assert fs.isdir(fs_join(target, "subdir"))
|
| 181 |
+
assert fs.isfile(fs_join(target, "subdir", "subfile1"))
|
| 182 |
+
assert fs.isfile(fs_join(target, "subdir", "subfile2"))
|
| 183 |
+
assert not fs.exists(fs_join(target, "subdir", "nesteddir"))
|
| 184 |
+
|
| 185 |
+
fs.rm(fs_join(target, "subdir"), recursive=True)
|
| 186 |
+
assert fs.ls(target, detail=False) == (
|
| 187 |
+
[] if supports_empty_directories else [dummy]
|
| 188 |
+
)
|
| 189 |
+
|
| 190 |
+
def test_copy_directory_to_new_directory(
|
| 191 |
+
self,
|
| 192 |
+
fs,
|
| 193 |
+
fs_join,
|
| 194 |
+
fs_bulk_operations_scenario_0,
|
| 195 |
+
fs_target,
|
| 196 |
+
supports_empty_directories,
|
| 197 |
+
):
|
| 198 |
+
# Copy scenario 1f
|
| 199 |
+
source = fs_bulk_operations_scenario_0
|
| 200 |
+
|
| 201 |
+
target = fs_target
|
| 202 |
+
fs.mkdir(target)
|
| 203 |
+
|
| 204 |
+
for source_slash, target_slash in zip([False, True], [False, True]):
|
| 205 |
+
s = fs_join(source, "subdir")
|
| 206 |
+
if source_slash:
|
| 207 |
+
s += "/"
|
| 208 |
+
t = fs_join(target, "newdir")
|
| 209 |
+
if target_slash:
|
| 210 |
+
t += "/"
|
| 211 |
+
|
| 212 |
+
# Without recursive does nothing
|
| 213 |
+
fs.cp(s, t)
|
| 214 |
+
if supports_empty_directories:
|
| 215 |
+
assert fs.ls(target) == []
|
| 216 |
+
else:
|
| 217 |
+
with pytest.raises(FileNotFoundError):
|
| 218 |
+
fs.ls(target)
|
| 219 |
+
|
| 220 |
+
# With recursive
|
| 221 |
+
fs.cp(s, t, recursive=True)
|
| 222 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 223 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile1"))
|
| 224 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile2"))
|
| 225 |
+
assert fs.isdir(fs_join(target, "newdir", "nesteddir"))
|
| 226 |
+
assert fs.isfile(fs_join(target, "newdir", "nesteddir", "nestedfile"))
|
| 227 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 228 |
+
|
| 229 |
+
fs.rm(fs_join(target, "newdir"), recursive=True)
|
| 230 |
+
assert not fs.exists(fs_join(target, "newdir"))
|
| 231 |
+
|
| 232 |
+
# Limit recursive by maxdepth
|
| 233 |
+
fs.cp(s, t, recursive=True, maxdepth=1)
|
| 234 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 235 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile1"))
|
| 236 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile2"))
|
| 237 |
+
assert not fs.exists(fs_join(target, "newdir", "nesteddir"))
|
| 238 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 239 |
+
|
| 240 |
+
fs.rm(fs_join(target, "newdir"), recursive=True)
|
| 241 |
+
assert not fs.exists(fs_join(target, "newdir"))
|
| 242 |
+
|
| 243 |
+
def test_copy_glob_to_existing_directory(
|
| 244 |
+
self,
|
| 245 |
+
fs,
|
| 246 |
+
fs_join,
|
| 247 |
+
fs_bulk_operations_scenario_0,
|
| 248 |
+
fs_target,
|
| 249 |
+
supports_empty_directories,
|
| 250 |
+
):
|
| 251 |
+
# Copy scenario 1g
|
| 252 |
+
source = fs_bulk_operations_scenario_0
|
| 253 |
+
|
| 254 |
+
target = fs_target
|
| 255 |
+
fs.mkdir(target)
|
| 256 |
+
if not supports_empty_directories:
|
| 257 |
+
# Force target directory to exist by adding a dummy file
|
| 258 |
+
dummy = fs_join(target, "dummy")
|
| 259 |
+
fs.touch(dummy)
|
| 260 |
+
assert fs.isdir(target)
|
| 261 |
+
|
| 262 |
+
for target_slash in [False, True]:
|
| 263 |
+
t = target + "/" if target_slash else target
|
| 264 |
+
|
| 265 |
+
# Without recursive
|
| 266 |
+
fs.cp(fs_join(source, "subdir", "*"), t)
|
| 267 |
+
assert fs.isfile(fs_join(target, "subfile1"))
|
| 268 |
+
assert fs.isfile(fs_join(target, "subfile2"))
|
| 269 |
+
assert not fs.isdir(fs_join(target, "nesteddir"))
|
| 270 |
+
assert not fs.exists(fs_join(target, "nesteddir", "nestedfile"))
|
| 271 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 272 |
+
|
| 273 |
+
fs.rm(
|
| 274 |
+
[
|
| 275 |
+
fs_join(target, "subfile1"),
|
| 276 |
+
fs_join(target, "subfile2"),
|
| 277 |
+
],
|
| 278 |
+
recursive=True,
|
| 279 |
+
)
|
| 280 |
+
assert fs.ls(target, detail=False) == (
|
| 281 |
+
[] if supports_empty_directories else [dummy]
|
| 282 |
+
)
|
| 283 |
+
|
| 284 |
+
# With recursive
|
| 285 |
+
for glob, recursive in zip(["*", "**"], [True, False]):
|
| 286 |
+
fs.cp(fs_join(source, "subdir", glob), t, recursive=recursive)
|
| 287 |
+
assert fs.isfile(fs_join(target, "subfile1"))
|
| 288 |
+
assert fs.isfile(fs_join(target, "subfile2"))
|
| 289 |
+
assert fs.isdir(fs_join(target, "nesteddir"))
|
| 290 |
+
assert fs.isfile(fs_join(target, "nesteddir", "nestedfile"))
|
| 291 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 292 |
+
|
| 293 |
+
fs.rm(
|
| 294 |
+
[
|
| 295 |
+
fs_join(target, "subfile1"),
|
| 296 |
+
fs_join(target, "subfile2"),
|
| 297 |
+
fs_join(target, "nesteddir"),
|
| 298 |
+
],
|
| 299 |
+
recursive=True,
|
| 300 |
+
)
|
| 301 |
+
assert fs.ls(target, detail=False) == (
|
| 302 |
+
[] if supports_empty_directories else [dummy]
|
| 303 |
+
)
|
| 304 |
+
|
| 305 |
+
# Limit recursive by maxdepth
|
| 306 |
+
fs.cp(
|
| 307 |
+
fs_join(source, "subdir", glob), t, recursive=recursive, maxdepth=1
|
| 308 |
+
)
|
| 309 |
+
assert fs.isfile(fs_join(target, "subfile1"))
|
| 310 |
+
assert fs.isfile(fs_join(target, "subfile2"))
|
| 311 |
+
assert not fs.exists(fs_join(target, "nesteddir"))
|
| 312 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 313 |
+
|
| 314 |
+
fs.rm(
|
| 315 |
+
[
|
| 316 |
+
fs_join(target, "subfile1"),
|
| 317 |
+
fs_join(target, "subfile2"),
|
| 318 |
+
],
|
| 319 |
+
recursive=True,
|
| 320 |
+
)
|
| 321 |
+
assert fs.ls(target, detail=False) == (
|
| 322 |
+
[] if supports_empty_directories else [dummy]
|
| 323 |
+
)
|
| 324 |
+
|
| 325 |
+
def test_copy_glob_to_new_directory(
|
| 326 |
+
self, fs, fs_join, fs_bulk_operations_scenario_0, fs_target
|
| 327 |
+
):
|
| 328 |
+
# Copy scenario 1h
|
| 329 |
+
source = fs_bulk_operations_scenario_0
|
| 330 |
+
|
| 331 |
+
target = fs_target
|
| 332 |
+
fs.mkdir(target)
|
| 333 |
+
|
| 334 |
+
for target_slash in [False, True]:
|
| 335 |
+
t = fs_join(target, "newdir")
|
| 336 |
+
if target_slash:
|
| 337 |
+
t += "/"
|
| 338 |
+
|
| 339 |
+
# Without recursive
|
| 340 |
+
fs.cp(fs_join(source, "subdir", "*"), t)
|
| 341 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 342 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile1"))
|
| 343 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile2"))
|
| 344 |
+
assert not fs.exists(fs_join(target, "newdir", "nesteddir"))
|
| 345 |
+
assert not fs.exists(fs_join(target, "newdir", "nesteddir", "nestedfile"))
|
| 346 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 347 |
+
assert not fs.exists(fs_join(target, "newdir", "subdir"))
|
| 348 |
+
|
| 349 |
+
fs.rm(fs_join(target, "newdir"), recursive=True)
|
| 350 |
+
assert not fs.exists(fs_join(target, "newdir"))
|
| 351 |
+
|
| 352 |
+
# With recursive
|
| 353 |
+
for glob, recursive in zip(["*", "**"], [True, False]):
|
| 354 |
+
fs.cp(fs_join(source, "subdir", glob), t, recursive=recursive)
|
| 355 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 356 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile1"))
|
| 357 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile2"))
|
| 358 |
+
assert fs.isdir(fs_join(target, "newdir", "nesteddir"))
|
| 359 |
+
assert fs.isfile(fs_join(target, "newdir", "nesteddir", "nestedfile"))
|
| 360 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 361 |
+
assert not fs.exists(fs_join(target, "newdir", "subdir"))
|
| 362 |
+
|
| 363 |
+
fs.rm(fs_join(target, "newdir"), recursive=True)
|
| 364 |
+
assert not fs.exists(fs_join(target, "newdir"))
|
| 365 |
+
|
| 366 |
+
# Limit recursive by maxdepth
|
| 367 |
+
fs.cp(
|
| 368 |
+
fs_join(source, "subdir", glob), t, recursive=recursive, maxdepth=1
|
| 369 |
+
)
|
| 370 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 371 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile1"))
|
| 372 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile2"))
|
| 373 |
+
assert not fs.exists(fs_join(target, "newdir", "nesteddir"))
|
| 374 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 375 |
+
assert not fs.exists(fs_join(target, "newdir", "subdir"))
|
| 376 |
+
|
| 377 |
+
fs.rm(fs_join(target, "newdir"), recursive=True)
|
| 378 |
+
assert not fs.exists(fs_join(target, "newdir"))
|
| 379 |
+
|
| 380 |
+
@pytest.mark.parametrize(
|
| 381 |
+
GLOB_EDGE_CASES_TESTS["argnames"],
|
| 382 |
+
GLOB_EDGE_CASES_TESTS["argvalues"],
|
| 383 |
+
)
|
| 384 |
+
def test_copy_glob_edge_cases(
|
| 385 |
+
self,
|
| 386 |
+
path,
|
| 387 |
+
recursive,
|
| 388 |
+
maxdepth,
|
| 389 |
+
expected,
|
| 390 |
+
fs,
|
| 391 |
+
fs_join,
|
| 392 |
+
fs_glob_edge_cases_files,
|
| 393 |
+
fs_target,
|
| 394 |
+
fs_sanitize_path,
|
| 395 |
+
):
|
| 396 |
+
# Copy scenario 1g
|
| 397 |
+
source = fs_glob_edge_cases_files
|
| 398 |
+
|
| 399 |
+
target = fs_target
|
| 400 |
+
|
| 401 |
+
for new_dir, target_slash in product([True, False], [True, False]):
|
| 402 |
+
fs.mkdir(target)
|
| 403 |
+
|
| 404 |
+
t = fs_join(target, "newdir") if new_dir else target
|
| 405 |
+
t = t + "/" if target_slash else t
|
| 406 |
+
|
| 407 |
+
fs.copy(fs_join(source, path), t, recursive=recursive, maxdepth=maxdepth)
|
| 408 |
+
|
| 409 |
+
output = fs.find(target)
|
| 410 |
+
if new_dir:
|
| 411 |
+
prefixed_expected = [
|
| 412 |
+
fs_sanitize_path(fs_join(target, "newdir", p)) for p in expected
|
| 413 |
+
]
|
| 414 |
+
else:
|
| 415 |
+
prefixed_expected = [
|
| 416 |
+
fs_sanitize_path(fs_join(target, p)) for p in expected
|
| 417 |
+
]
|
| 418 |
+
assert sorted(output) == sorted(prefixed_expected)
|
| 419 |
+
|
| 420 |
+
try:
|
| 421 |
+
fs.rm(target, recursive=True)
|
| 422 |
+
except FileNotFoundError:
|
| 423 |
+
pass
|
| 424 |
+
|
| 425 |
+
def test_copy_list_of_files_to_existing_directory(
|
| 426 |
+
self,
|
| 427 |
+
fs,
|
| 428 |
+
fs_join,
|
| 429 |
+
fs_bulk_operations_scenario_0,
|
| 430 |
+
fs_target,
|
| 431 |
+
supports_empty_directories,
|
| 432 |
+
):
|
| 433 |
+
# Copy scenario 2a
|
| 434 |
+
source = fs_bulk_operations_scenario_0
|
| 435 |
+
|
| 436 |
+
target = fs_target
|
| 437 |
+
fs.mkdir(target)
|
| 438 |
+
if not supports_empty_directories:
|
| 439 |
+
# Force target directory to exist by adding a dummy file
|
| 440 |
+
dummy = fs_join(target, "dummy")
|
| 441 |
+
fs.touch(dummy)
|
| 442 |
+
assert fs.isdir(target)
|
| 443 |
+
|
| 444 |
+
source_files = [
|
| 445 |
+
fs_join(source, "file1"),
|
| 446 |
+
fs_join(source, "file2"),
|
| 447 |
+
fs_join(source, "subdir", "subfile1"),
|
| 448 |
+
]
|
| 449 |
+
|
| 450 |
+
for target_slash in [False, True]:
|
| 451 |
+
t = target + "/" if target_slash else target
|
| 452 |
+
|
| 453 |
+
fs.cp(source_files, t)
|
| 454 |
+
assert fs.isfile(fs_join(target, "file1"))
|
| 455 |
+
assert fs.isfile(fs_join(target, "file2"))
|
| 456 |
+
assert fs.isfile(fs_join(target, "subfile1"))
|
| 457 |
+
|
| 458 |
+
fs.rm(
|
| 459 |
+
[
|
| 460 |
+
fs_join(target, "file1"),
|
| 461 |
+
fs_join(target, "file2"),
|
| 462 |
+
fs_join(target, "subfile1"),
|
| 463 |
+
],
|
| 464 |
+
recursive=True,
|
| 465 |
+
)
|
| 466 |
+
assert fs.ls(target, detail=False) == (
|
| 467 |
+
[] if supports_empty_directories else [dummy]
|
| 468 |
+
)
|
| 469 |
+
|
| 470 |
+
def test_copy_list_of_files_to_new_directory(
|
| 471 |
+
self, fs, fs_join, fs_bulk_operations_scenario_0, fs_target
|
| 472 |
+
):
|
| 473 |
+
# Copy scenario 2b
|
| 474 |
+
source = fs_bulk_operations_scenario_0
|
| 475 |
+
|
| 476 |
+
target = fs_target
|
| 477 |
+
fs.mkdir(target)
|
| 478 |
+
|
| 479 |
+
source_files = [
|
| 480 |
+
fs_join(source, "file1"),
|
| 481 |
+
fs_join(source, "file2"),
|
| 482 |
+
fs_join(source, "subdir", "subfile1"),
|
| 483 |
+
]
|
| 484 |
+
|
| 485 |
+
fs.cp(source_files, fs_join(target, "newdir") + "/") # Note trailing slash
|
| 486 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 487 |
+
assert fs.isfile(fs_join(target, "newdir", "file1"))
|
| 488 |
+
assert fs.isfile(fs_join(target, "newdir", "file2"))
|
| 489 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile1"))
|
| 490 |
+
|
| 491 |
+
def test_copy_two_files_new_directory(
|
| 492 |
+
self, fs, fs_join, fs_bulk_operations_scenario_0, fs_target
|
| 493 |
+
):
|
| 494 |
+
# This is a duplicate of test_copy_list_of_files_to_new_directory and
|
| 495 |
+
# can eventually be removed.
|
| 496 |
+
source = fs_bulk_operations_scenario_0
|
| 497 |
+
|
| 498 |
+
target = fs_target
|
| 499 |
+
assert not fs.exists(target)
|
| 500 |
+
fs.cp([fs_join(source, "file1"), fs_join(source, "file2")], target)
|
| 501 |
+
|
| 502 |
+
assert fs.isdir(target)
|
| 503 |
+
assert fs.isfile(fs_join(target, "file1"))
|
| 504 |
+
assert fs.isfile(fs_join(target, "file2"))
|
| 505 |
+
|
| 506 |
+
def test_copy_directory_without_files_with_same_name_prefix(
|
| 507 |
+
self,
|
| 508 |
+
fs,
|
| 509 |
+
fs_join,
|
| 510 |
+
fs_target,
|
| 511 |
+
fs_dir_and_file_with_same_name_prefix,
|
| 512 |
+
supports_empty_directories,
|
| 513 |
+
):
|
| 514 |
+
# Create the test dirs
|
| 515 |
+
source = fs_dir_and_file_with_same_name_prefix
|
| 516 |
+
target = fs_target
|
| 517 |
+
|
| 518 |
+
# Test without glob
|
| 519 |
+
fs.cp(fs_join(source, "subdir"), target, recursive=True)
|
| 520 |
+
|
| 521 |
+
assert fs.isfile(fs_join(target, "subfile.txt"))
|
| 522 |
+
assert not fs.isfile(fs_join(target, "subdir.txt"))
|
| 523 |
+
|
| 524 |
+
fs.rm([fs_join(target, "subfile.txt")])
|
| 525 |
+
if supports_empty_directories:
|
| 526 |
+
assert fs.ls(target) == []
|
| 527 |
+
else:
|
| 528 |
+
assert not fs.exists(target)
|
| 529 |
+
|
| 530 |
+
# Test with glob
|
| 531 |
+
fs.cp(fs_join(source, "subdir*"), target, recursive=True)
|
| 532 |
+
|
| 533 |
+
assert fs.isdir(fs_join(target, "subdir"))
|
| 534 |
+
assert fs.isfile(fs_join(target, "subdir", "subfile.txt"))
|
| 535 |
+
assert fs.isfile(fs_join(target, "subdir.txt"))
|
| 536 |
+
|
| 537 |
+
def test_copy_with_source_and_destination_as_list(
|
| 538 |
+
self, fs, fs_target, fs_join, fs_10_files_with_hashed_names
|
| 539 |
+
):
|
| 540 |
+
# Create the test dir
|
| 541 |
+
source = fs_10_files_with_hashed_names
|
| 542 |
+
target = fs_target
|
| 543 |
+
|
| 544 |
+
# Create list of files for source and destination
|
| 545 |
+
source_files = []
|
| 546 |
+
destination_files = []
|
| 547 |
+
for i in range(10):
|
| 548 |
+
hashed_i = md5(str(i).encode("utf-8")).hexdigest()
|
| 549 |
+
source_files.append(fs_join(source, f"{hashed_i}.txt"))
|
| 550 |
+
destination_files.append(fs_join(target, f"{hashed_i}.txt"))
|
| 551 |
+
|
| 552 |
+
# Copy and assert order was kept
|
| 553 |
+
fs.copy(path1=source_files, path2=destination_files)
|
| 554 |
+
|
| 555 |
+
for i in range(10):
|
| 556 |
+
file_content = fs.cat(destination_files[i]).decode("utf-8")
|
| 557 |
+
assert file_content == str(i)
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/get.py
ADDED
|
@@ -0,0 +1,587 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from hashlib import md5
|
| 2 |
+
from itertools import product
|
| 3 |
+
|
| 4 |
+
import pytest
|
| 5 |
+
|
| 6 |
+
from fsspec.implementations.local import make_path_posix
|
| 7 |
+
from fsspec.tests.abstract.common import GLOB_EDGE_CASES_TESTS
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class AbstractGetTests:
|
| 11 |
+
def test_get_file_to_existing_directory(
|
| 12 |
+
self,
|
| 13 |
+
fs,
|
| 14 |
+
fs_join,
|
| 15 |
+
fs_bulk_operations_scenario_0,
|
| 16 |
+
local_fs,
|
| 17 |
+
local_join,
|
| 18 |
+
local_target,
|
| 19 |
+
):
|
| 20 |
+
# Copy scenario 1a
|
| 21 |
+
source = fs_bulk_operations_scenario_0
|
| 22 |
+
|
| 23 |
+
target = local_target
|
| 24 |
+
local_fs.mkdir(target)
|
| 25 |
+
assert local_fs.isdir(target)
|
| 26 |
+
|
| 27 |
+
target_file2 = local_join(target, "file2")
|
| 28 |
+
target_subfile1 = local_join(target, "subfile1")
|
| 29 |
+
|
| 30 |
+
# Copy from source directory
|
| 31 |
+
fs.get(fs_join(source, "file2"), target)
|
| 32 |
+
assert local_fs.isfile(target_file2)
|
| 33 |
+
|
| 34 |
+
# Copy from sub directory
|
| 35 |
+
fs.get(fs_join(source, "subdir", "subfile1"), target)
|
| 36 |
+
assert local_fs.isfile(target_subfile1)
|
| 37 |
+
|
| 38 |
+
# Remove copied files
|
| 39 |
+
local_fs.rm([target_file2, target_subfile1])
|
| 40 |
+
assert not local_fs.exists(target_file2)
|
| 41 |
+
assert not local_fs.exists(target_subfile1)
|
| 42 |
+
|
| 43 |
+
# Repeat with trailing slash on target
|
| 44 |
+
fs.get(fs_join(source, "file2"), target + "/")
|
| 45 |
+
assert local_fs.isdir(target)
|
| 46 |
+
assert local_fs.isfile(target_file2)
|
| 47 |
+
|
| 48 |
+
fs.get(fs_join(source, "subdir", "subfile1"), target + "/")
|
| 49 |
+
assert local_fs.isfile(target_subfile1)
|
| 50 |
+
|
| 51 |
+
def test_get_file_to_new_directory(
|
| 52 |
+
self,
|
| 53 |
+
fs,
|
| 54 |
+
fs_join,
|
| 55 |
+
fs_bulk_operations_scenario_0,
|
| 56 |
+
local_fs,
|
| 57 |
+
local_join,
|
| 58 |
+
local_target,
|
| 59 |
+
):
|
| 60 |
+
# Copy scenario 1b
|
| 61 |
+
source = fs_bulk_operations_scenario_0
|
| 62 |
+
|
| 63 |
+
target = local_target
|
| 64 |
+
local_fs.mkdir(target)
|
| 65 |
+
|
| 66 |
+
fs.get(
|
| 67 |
+
fs_join(source, "subdir", "subfile1"), local_join(target, "newdir/")
|
| 68 |
+
) # Note trailing slash
|
| 69 |
+
|
| 70 |
+
assert local_fs.isdir(target)
|
| 71 |
+
assert local_fs.isdir(local_join(target, "newdir"))
|
| 72 |
+
assert local_fs.isfile(local_join(target, "newdir", "subfile1"))
|
| 73 |
+
|
| 74 |
+
def test_get_file_to_file_in_existing_directory(
|
| 75 |
+
self,
|
| 76 |
+
fs,
|
| 77 |
+
fs_join,
|
| 78 |
+
fs_bulk_operations_scenario_0,
|
| 79 |
+
local_fs,
|
| 80 |
+
local_join,
|
| 81 |
+
local_target,
|
| 82 |
+
):
|
| 83 |
+
# Copy scenario 1c
|
| 84 |
+
source = fs_bulk_operations_scenario_0
|
| 85 |
+
|
| 86 |
+
target = local_target
|
| 87 |
+
local_fs.mkdir(target)
|
| 88 |
+
|
| 89 |
+
fs.get(fs_join(source, "subdir", "subfile1"), local_join(target, "newfile"))
|
| 90 |
+
assert local_fs.isfile(local_join(target, "newfile"))
|
| 91 |
+
|
| 92 |
+
def test_get_file_to_file_in_new_directory(
|
| 93 |
+
self,
|
| 94 |
+
fs,
|
| 95 |
+
fs_join,
|
| 96 |
+
fs_bulk_operations_scenario_0,
|
| 97 |
+
local_fs,
|
| 98 |
+
local_join,
|
| 99 |
+
local_target,
|
| 100 |
+
):
|
| 101 |
+
# Copy scenario 1d
|
| 102 |
+
source = fs_bulk_operations_scenario_0
|
| 103 |
+
|
| 104 |
+
target = local_target
|
| 105 |
+
local_fs.mkdir(target)
|
| 106 |
+
|
| 107 |
+
fs.get(
|
| 108 |
+
fs_join(source, "subdir", "subfile1"),
|
| 109 |
+
local_join(target, "newdir", "newfile"),
|
| 110 |
+
)
|
| 111 |
+
assert local_fs.isdir(local_join(target, "newdir"))
|
| 112 |
+
assert local_fs.isfile(local_join(target, "newdir", "newfile"))
|
| 113 |
+
|
| 114 |
+
def test_get_directory_to_existing_directory(
|
| 115 |
+
self,
|
| 116 |
+
fs,
|
| 117 |
+
fs_join,
|
| 118 |
+
fs_bulk_operations_scenario_0,
|
| 119 |
+
local_fs,
|
| 120 |
+
local_join,
|
| 121 |
+
local_target,
|
| 122 |
+
):
|
| 123 |
+
# Copy scenario 1e
|
| 124 |
+
source = fs_bulk_operations_scenario_0
|
| 125 |
+
|
| 126 |
+
target = local_target
|
| 127 |
+
local_fs.mkdir(target)
|
| 128 |
+
assert local_fs.isdir(target)
|
| 129 |
+
|
| 130 |
+
for source_slash, target_slash in zip([False, True], [False, True]):
|
| 131 |
+
s = fs_join(source, "subdir")
|
| 132 |
+
if source_slash:
|
| 133 |
+
s += "/"
|
| 134 |
+
t = target + "/" if target_slash else target
|
| 135 |
+
|
| 136 |
+
# Without recursive does nothing
|
| 137 |
+
fs.get(s, t)
|
| 138 |
+
assert local_fs.ls(target) == []
|
| 139 |
+
|
| 140 |
+
# With recursive
|
| 141 |
+
fs.get(s, t, recursive=True)
|
| 142 |
+
if source_slash:
|
| 143 |
+
assert local_fs.isfile(local_join(target, "subfile1"))
|
| 144 |
+
assert local_fs.isfile(local_join(target, "subfile2"))
|
| 145 |
+
assert local_fs.isdir(local_join(target, "nesteddir"))
|
| 146 |
+
assert local_fs.isfile(local_join(target, "nesteddir", "nestedfile"))
|
| 147 |
+
assert not local_fs.exists(local_join(target, "subdir"))
|
| 148 |
+
|
| 149 |
+
local_fs.rm(
|
| 150 |
+
[
|
| 151 |
+
local_join(target, "subfile1"),
|
| 152 |
+
local_join(target, "subfile2"),
|
| 153 |
+
local_join(target, "nesteddir"),
|
| 154 |
+
],
|
| 155 |
+
recursive=True,
|
| 156 |
+
)
|
| 157 |
+
else:
|
| 158 |
+
assert local_fs.isdir(local_join(target, "subdir"))
|
| 159 |
+
assert local_fs.isfile(local_join(target, "subdir", "subfile1"))
|
| 160 |
+
assert local_fs.isfile(local_join(target, "subdir", "subfile2"))
|
| 161 |
+
assert local_fs.isdir(local_join(target, "subdir", "nesteddir"))
|
| 162 |
+
assert local_fs.isfile(
|
| 163 |
+
local_join(target, "subdir", "nesteddir", "nestedfile")
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
+
local_fs.rm(local_join(target, "subdir"), recursive=True)
|
| 167 |
+
assert local_fs.ls(target) == []
|
| 168 |
+
|
| 169 |
+
# Limit recursive by maxdepth
|
| 170 |
+
fs.get(s, t, recursive=True, maxdepth=1)
|
| 171 |
+
if source_slash:
|
| 172 |
+
assert local_fs.isfile(local_join(target, "subfile1"))
|
| 173 |
+
assert local_fs.isfile(local_join(target, "subfile2"))
|
| 174 |
+
assert not local_fs.exists(local_join(target, "nesteddir"))
|
| 175 |
+
assert not local_fs.exists(local_join(target, "subdir"))
|
| 176 |
+
|
| 177 |
+
local_fs.rm(
|
| 178 |
+
[
|
| 179 |
+
local_join(target, "subfile1"),
|
| 180 |
+
local_join(target, "subfile2"),
|
| 181 |
+
],
|
| 182 |
+
recursive=True,
|
| 183 |
+
)
|
| 184 |
+
else:
|
| 185 |
+
assert local_fs.isdir(local_join(target, "subdir"))
|
| 186 |
+
assert local_fs.isfile(local_join(target, "subdir", "subfile1"))
|
| 187 |
+
assert local_fs.isfile(local_join(target, "subdir", "subfile2"))
|
| 188 |
+
assert not local_fs.exists(local_join(target, "subdir", "nesteddir"))
|
| 189 |
+
|
| 190 |
+
local_fs.rm(local_join(target, "subdir"), recursive=True)
|
| 191 |
+
assert local_fs.ls(target) == []
|
| 192 |
+
|
| 193 |
+
def test_get_directory_to_new_directory(
|
| 194 |
+
self,
|
| 195 |
+
fs,
|
| 196 |
+
fs_join,
|
| 197 |
+
fs_bulk_operations_scenario_0,
|
| 198 |
+
local_fs,
|
| 199 |
+
local_join,
|
| 200 |
+
local_target,
|
| 201 |
+
):
|
| 202 |
+
# Copy scenario 1f
|
| 203 |
+
source = fs_bulk_operations_scenario_0
|
| 204 |
+
|
| 205 |
+
target = local_target
|
| 206 |
+
local_fs.mkdir(target)
|
| 207 |
+
|
| 208 |
+
for source_slash, target_slash in zip([False, True], [False, True]):
|
| 209 |
+
s = fs_join(source, "subdir")
|
| 210 |
+
if source_slash:
|
| 211 |
+
s += "/"
|
| 212 |
+
t = local_join(target, "newdir")
|
| 213 |
+
if target_slash:
|
| 214 |
+
t += "/"
|
| 215 |
+
|
| 216 |
+
# Without recursive does nothing
|
| 217 |
+
fs.get(s, t)
|
| 218 |
+
assert local_fs.ls(target) == []
|
| 219 |
+
|
| 220 |
+
# With recursive
|
| 221 |
+
fs.get(s, t, recursive=True)
|
| 222 |
+
assert local_fs.isdir(local_join(target, "newdir"))
|
| 223 |
+
assert local_fs.isfile(local_join(target, "newdir", "subfile1"))
|
| 224 |
+
assert local_fs.isfile(local_join(target, "newdir", "subfile2"))
|
| 225 |
+
assert local_fs.isdir(local_join(target, "newdir", "nesteddir"))
|
| 226 |
+
assert local_fs.isfile(
|
| 227 |
+
local_join(target, "newdir", "nesteddir", "nestedfile")
|
| 228 |
+
)
|
| 229 |
+
assert not local_fs.exists(local_join(target, "subdir"))
|
| 230 |
+
|
| 231 |
+
local_fs.rm(local_join(target, "newdir"), recursive=True)
|
| 232 |
+
assert local_fs.ls(target) == []
|
| 233 |
+
|
| 234 |
+
# Limit recursive by maxdepth
|
| 235 |
+
fs.get(s, t, recursive=True, maxdepth=1)
|
| 236 |
+
assert local_fs.isdir(local_join(target, "newdir"))
|
| 237 |
+
assert local_fs.isfile(local_join(target, "newdir", "subfile1"))
|
| 238 |
+
assert local_fs.isfile(local_join(target, "newdir", "subfile2"))
|
| 239 |
+
assert not local_fs.exists(local_join(target, "newdir", "nesteddir"))
|
| 240 |
+
assert not local_fs.exists(local_join(target, "subdir"))
|
| 241 |
+
|
| 242 |
+
local_fs.rm(local_join(target, "newdir"), recursive=True)
|
| 243 |
+
assert not local_fs.exists(local_join(target, "newdir"))
|
| 244 |
+
|
| 245 |
+
def test_get_glob_to_existing_directory(
|
| 246 |
+
self,
|
| 247 |
+
fs,
|
| 248 |
+
fs_join,
|
| 249 |
+
fs_bulk_operations_scenario_0,
|
| 250 |
+
local_fs,
|
| 251 |
+
local_join,
|
| 252 |
+
local_target,
|
| 253 |
+
):
|
| 254 |
+
# Copy scenario 1g
|
| 255 |
+
source = fs_bulk_operations_scenario_0
|
| 256 |
+
|
| 257 |
+
target = local_target
|
| 258 |
+
local_fs.mkdir(target)
|
| 259 |
+
|
| 260 |
+
for target_slash in [False, True]:
|
| 261 |
+
t = target + "/" if target_slash else target
|
| 262 |
+
|
| 263 |
+
# Without recursive
|
| 264 |
+
fs.get(fs_join(source, "subdir", "*"), t)
|
| 265 |
+
assert local_fs.isfile(local_join(target, "subfile1"))
|
| 266 |
+
assert local_fs.isfile(local_join(target, "subfile2"))
|
| 267 |
+
assert not local_fs.isdir(local_join(target, "nesteddir"))
|
| 268 |
+
assert not local_fs.exists(local_join(target, "nesteddir", "nestedfile"))
|
| 269 |
+
assert not local_fs.exists(local_join(target, "subdir"))
|
| 270 |
+
|
| 271 |
+
local_fs.rm(
|
| 272 |
+
[
|
| 273 |
+
local_join(target, "subfile1"),
|
| 274 |
+
local_join(target, "subfile2"),
|
| 275 |
+
],
|
| 276 |
+
recursive=True,
|
| 277 |
+
)
|
| 278 |
+
assert local_fs.ls(target) == []
|
| 279 |
+
|
| 280 |
+
# With recursive
|
| 281 |
+
for glob, recursive in zip(["*", "**"], [True, False]):
|
| 282 |
+
fs.get(fs_join(source, "subdir", glob), t, recursive=recursive)
|
| 283 |
+
assert local_fs.isfile(local_join(target, "subfile1"))
|
| 284 |
+
assert local_fs.isfile(local_join(target, "subfile2"))
|
| 285 |
+
assert local_fs.isdir(local_join(target, "nesteddir"))
|
| 286 |
+
assert local_fs.isfile(local_join(target, "nesteddir", "nestedfile"))
|
| 287 |
+
assert not local_fs.exists(local_join(target, "subdir"))
|
| 288 |
+
|
| 289 |
+
local_fs.rm(
|
| 290 |
+
[
|
| 291 |
+
local_join(target, "subfile1"),
|
| 292 |
+
local_join(target, "subfile2"),
|
| 293 |
+
local_join(target, "nesteddir"),
|
| 294 |
+
],
|
| 295 |
+
recursive=True,
|
| 296 |
+
)
|
| 297 |
+
assert local_fs.ls(target) == []
|
| 298 |
+
|
| 299 |
+
# Limit recursive by maxdepth
|
| 300 |
+
fs.get(
|
| 301 |
+
fs_join(source, "subdir", glob), t, recursive=recursive, maxdepth=1
|
| 302 |
+
)
|
| 303 |
+
assert local_fs.isfile(local_join(target, "subfile1"))
|
| 304 |
+
assert local_fs.isfile(local_join(target, "subfile2"))
|
| 305 |
+
assert not local_fs.exists(local_join(target, "nesteddir"))
|
| 306 |
+
assert not local_fs.exists(local_join(target, "subdir"))
|
| 307 |
+
|
| 308 |
+
local_fs.rm(
|
| 309 |
+
[
|
| 310 |
+
local_join(target, "subfile1"),
|
| 311 |
+
local_join(target, "subfile2"),
|
| 312 |
+
],
|
| 313 |
+
recursive=True,
|
| 314 |
+
)
|
| 315 |
+
assert local_fs.ls(target) == []
|
| 316 |
+
|
| 317 |
+
def test_get_glob_to_new_directory(
|
| 318 |
+
self,
|
| 319 |
+
fs,
|
| 320 |
+
fs_join,
|
| 321 |
+
fs_bulk_operations_scenario_0,
|
| 322 |
+
local_fs,
|
| 323 |
+
local_join,
|
| 324 |
+
local_target,
|
| 325 |
+
):
|
| 326 |
+
# Copy scenario 1h
|
| 327 |
+
source = fs_bulk_operations_scenario_0
|
| 328 |
+
|
| 329 |
+
target = local_target
|
| 330 |
+
local_fs.mkdir(target)
|
| 331 |
+
|
| 332 |
+
for target_slash in [False, True]:
|
| 333 |
+
t = fs_join(target, "newdir")
|
| 334 |
+
if target_slash:
|
| 335 |
+
t += "/"
|
| 336 |
+
|
| 337 |
+
# Without recursive
|
| 338 |
+
fs.get(fs_join(source, "subdir", "*"), t)
|
| 339 |
+
assert local_fs.isdir(local_join(target, "newdir"))
|
| 340 |
+
assert local_fs.isfile(local_join(target, "newdir", "subfile1"))
|
| 341 |
+
assert local_fs.isfile(local_join(target, "newdir", "subfile2"))
|
| 342 |
+
assert not local_fs.exists(local_join(target, "newdir", "nesteddir"))
|
| 343 |
+
assert not local_fs.exists(
|
| 344 |
+
local_join(target, "newdir", "nesteddir", "nestedfile")
|
| 345 |
+
)
|
| 346 |
+
assert not local_fs.exists(local_join(target, "subdir"))
|
| 347 |
+
assert not local_fs.exists(local_join(target, "newdir", "subdir"))
|
| 348 |
+
|
| 349 |
+
local_fs.rm(local_join(target, "newdir"), recursive=True)
|
| 350 |
+
assert local_fs.ls(target) == []
|
| 351 |
+
|
| 352 |
+
# With recursive
|
| 353 |
+
for glob, recursive in zip(["*", "**"], [True, False]):
|
| 354 |
+
fs.get(fs_join(source, "subdir", glob), t, recursive=recursive)
|
| 355 |
+
assert local_fs.isdir(local_join(target, "newdir"))
|
| 356 |
+
assert local_fs.isfile(local_join(target, "newdir", "subfile1"))
|
| 357 |
+
assert local_fs.isfile(local_join(target, "newdir", "subfile2"))
|
| 358 |
+
assert local_fs.isdir(local_join(target, "newdir", "nesteddir"))
|
| 359 |
+
assert local_fs.isfile(
|
| 360 |
+
local_join(target, "newdir", "nesteddir", "nestedfile")
|
| 361 |
+
)
|
| 362 |
+
assert not local_fs.exists(local_join(target, "subdir"))
|
| 363 |
+
assert not local_fs.exists(local_join(target, "newdir", "subdir"))
|
| 364 |
+
|
| 365 |
+
local_fs.rm(local_join(target, "newdir"), recursive=True)
|
| 366 |
+
assert not local_fs.exists(local_join(target, "newdir"))
|
| 367 |
+
|
| 368 |
+
# Limit recursive by maxdepth
|
| 369 |
+
fs.get(
|
| 370 |
+
fs_join(source, "subdir", glob), t, recursive=recursive, maxdepth=1
|
| 371 |
+
)
|
| 372 |
+
assert local_fs.isdir(local_join(target, "newdir"))
|
| 373 |
+
assert local_fs.isfile(local_join(target, "newdir", "subfile1"))
|
| 374 |
+
assert local_fs.isfile(local_join(target, "newdir", "subfile2"))
|
| 375 |
+
assert not local_fs.exists(local_join(target, "newdir", "nesteddir"))
|
| 376 |
+
assert not local_fs.exists(local_join(target, "subdir"))
|
| 377 |
+
assert not local_fs.exists(local_join(target, "newdir", "subdir"))
|
| 378 |
+
|
| 379 |
+
local_fs.rm(local_fs.ls(target, detail=False), recursive=True)
|
| 380 |
+
assert not local_fs.exists(local_join(target, "newdir"))
|
| 381 |
+
|
| 382 |
+
@pytest.mark.parametrize(
|
| 383 |
+
GLOB_EDGE_CASES_TESTS["argnames"],
|
| 384 |
+
GLOB_EDGE_CASES_TESTS["argvalues"],
|
| 385 |
+
)
|
| 386 |
+
def test_get_glob_edge_cases(
|
| 387 |
+
self,
|
| 388 |
+
path,
|
| 389 |
+
recursive,
|
| 390 |
+
maxdepth,
|
| 391 |
+
expected,
|
| 392 |
+
fs,
|
| 393 |
+
fs_join,
|
| 394 |
+
fs_glob_edge_cases_files,
|
| 395 |
+
local_fs,
|
| 396 |
+
local_join,
|
| 397 |
+
local_target,
|
| 398 |
+
):
|
| 399 |
+
# Copy scenario 1g
|
| 400 |
+
source = fs_glob_edge_cases_files
|
| 401 |
+
|
| 402 |
+
target = local_target
|
| 403 |
+
|
| 404 |
+
for new_dir, target_slash in product([True, False], [True, False]):
|
| 405 |
+
local_fs.mkdir(target)
|
| 406 |
+
|
| 407 |
+
t = local_join(target, "newdir") if new_dir else target
|
| 408 |
+
t = t + "/" if target_slash else t
|
| 409 |
+
|
| 410 |
+
fs.get(fs_join(source, path), t, recursive=recursive, maxdepth=maxdepth)
|
| 411 |
+
|
| 412 |
+
output = local_fs.find(target)
|
| 413 |
+
if new_dir:
|
| 414 |
+
prefixed_expected = [
|
| 415 |
+
make_path_posix(local_join(target, "newdir", p)) for p in expected
|
| 416 |
+
]
|
| 417 |
+
else:
|
| 418 |
+
prefixed_expected = [
|
| 419 |
+
make_path_posix(local_join(target, p)) for p in expected
|
| 420 |
+
]
|
| 421 |
+
assert sorted(output) == sorted(prefixed_expected)
|
| 422 |
+
|
| 423 |
+
try:
|
| 424 |
+
local_fs.rm(target, recursive=True)
|
| 425 |
+
except FileNotFoundError:
|
| 426 |
+
pass
|
| 427 |
+
|
| 428 |
+
def test_get_list_of_files_to_existing_directory(
|
| 429 |
+
self,
|
| 430 |
+
fs,
|
| 431 |
+
fs_join,
|
| 432 |
+
fs_bulk_operations_scenario_0,
|
| 433 |
+
local_fs,
|
| 434 |
+
local_join,
|
| 435 |
+
local_target,
|
| 436 |
+
):
|
| 437 |
+
# Copy scenario 2a
|
| 438 |
+
source = fs_bulk_operations_scenario_0
|
| 439 |
+
|
| 440 |
+
target = local_target
|
| 441 |
+
local_fs.mkdir(target)
|
| 442 |
+
|
| 443 |
+
source_files = [
|
| 444 |
+
fs_join(source, "file1"),
|
| 445 |
+
fs_join(source, "file2"),
|
| 446 |
+
fs_join(source, "subdir", "subfile1"),
|
| 447 |
+
]
|
| 448 |
+
|
| 449 |
+
for target_slash in [False, True]:
|
| 450 |
+
t = target + "/" if target_slash else target
|
| 451 |
+
|
| 452 |
+
fs.get(source_files, t)
|
| 453 |
+
assert local_fs.isfile(local_join(target, "file1"))
|
| 454 |
+
assert local_fs.isfile(local_join(target, "file2"))
|
| 455 |
+
assert local_fs.isfile(local_join(target, "subfile1"))
|
| 456 |
+
|
| 457 |
+
local_fs.rm(
|
| 458 |
+
[
|
| 459 |
+
local_join(target, "file1"),
|
| 460 |
+
local_join(target, "file2"),
|
| 461 |
+
local_join(target, "subfile1"),
|
| 462 |
+
],
|
| 463 |
+
recursive=True,
|
| 464 |
+
)
|
| 465 |
+
assert local_fs.ls(target) == []
|
| 466 |
+
|
| 467 |
+
def test_get_list_of_files_to_new_directory(
|
| 468 |
+
self,
|
| 469 |
+
fs,
|
| 470 |
+
fs_join,
|
| 471 |
+
fs_bulk_operations_scenario_0,
|
| 472 |
+
local_fs,
|
| 473 |
+
local_join,
|
| 474 |
+
local_target,
|
| 475 |
+
):
|
| 476 |
+
# Copy scenario 2b
|
| 477 |
+
source = fs_bulk_operations_scenario_0
|
| 478 |
+
|
| 479 |
+
target = local_target
|
| 480 |
+
local_fs.mkdir(target)
|
| 481 |
+
|
| 482 |
+
source_files = [
|
| 483 |
+
fs_join(source, "file1"),
|
| 484 |
+
fs_join(source, "file2"),
|
| 485 |
+
fs_join(source, "subdir", "subfile1"),
|
| 486 |
+
]
|
| 487 |
+
|
| 488 |
+
fs.get(source_files, local_join(target, "newdir") + "/") # Note trailing slash
|
| 489 |
+
assert local_fs.isdir(local_join(target, "newdir"))
|
| 490 |
+
assert local_fs.isfile(local_join(target, "newdir", "file1"))
|
| 491 |
+
assert local_fs.isfile(local_join(target, "newdir", "file2"))
|
| 492 |
+
assert local_fs.isfile(local_join(target, "newdir", "subfile1"))
|
| 493 |
+
|
| 494 |
+
def test_get_directory_recursive(
|
| 495 |
+
self, fs, fs_join, fs_path, local_fs, local_join, local_target
|
| 496 |
+
):
|
| 497 |
+
# https://github.com/fsspec/filesystem_spec/issues/1062
|
| 498 |
+
# Recursive cp/get/put of source directory into non-existent target directory.
|
| 499 |
+
src = fs_join(fs_path, "src")
|
| 500 |
+
src_file = fs_join(src, "file")
|
| 501 |
+
fs.mkdir(src)
|
| 502 |
+
fs.touch(src_file)
|
| 503 |
+
|
| 504 |
+
target = local_target
|
| 505 |
+
|
| 506 |
+
# get without slash
|
| 507 |
+
assert not local_fs.exists(target)
|
| 508 |
+
for loop in range(2):
|
| 509 |
+
fs.get(src, target, recursive=True)
|
| 510 |
+
assert local_fs.isdir(target)
|
| 511 |
+
|
| 512 |
+
if loop == 0:
|
| 513 |
+
assert local_fs.isfile(local_join(target, "file"))
|
| 514 |
+
assert not local_fs.exists(local_join(target, "src"))
|
| 515 |
+
else:
|
| 516 |
+
assert local_fs.isfile(local_join(target, "file"))
|
| 517 |
+
assert local_fs.isdir(local_join(target, "src"))
|
| 518 |
+
assert local_fs.isfile(local_join(target, "src", "file"))
|
| 519 |
+
|
| 520 |
+
local_fs.rm(target, recursive=True)
|
| 521 |
+
|
| 522 |
+
# get with slash
|
| 523 |
+
assert not local_fs.exists(target)
|
| 524 |
+
for loop in range(2):
|
| 525 |
+
fs.get(src + "/", target, recursive=True)
|
| 526 |
+
assert local_fs.isdir(target)
|
| 527 |
+
assert local_fs.isfile(local_join(target, "file"))
|
| 528 |
+
assert not local_fs.exists(local_join(target, "src"))
|
| 529 |
+
|
| 530 |
+
def test_get_directory_without_files_with_same_name_prefix(
|
| 531 |
+
self,
|
| 532 |
+
fs,
|
| 533 |
+
fs_join,
|
| 534 |
+
local_fs,
|
| 535 |
+
local_join,
|
| 536 |
+
local_target,
|
| 537 |
+
fs_dir_and_file_with_same_name_prefix,
|
| 538 |
+
):
|
| 539 |
+
# Create the test dirs
|
| 540 |
+
source = fs_dir_and_file_with_same_name_prefix
|
| 541 |
+
target = local_target
|
| 542 |
+
|
| 543 |
+
# Test without glob
|
| 544 |
+
fs.get(fs_join(source, "subdir"), target, recursive=True)
|
| 545 |
+
|
| 546 |
+
assert local_fs.isfile(local_join(target, "subfile.txt"))
|
| 547 |
+
assert not local_fs.isfile(local_join(target, "subdir.txt"))
|
| 548 |
+
|
| 549 |
+
local_fs.rm([local_join(target, "subfile.txt")])
|
| 550 |
+
assert local_fs.ls(target) == []
|
| 551 |
+
|
| 552 |
+
# Test with glob
|
| 553 |
+
fs.get(fs_join(source, "subdir*"), target, recursive=True)
|
| 554 |
+
|
| 555 |
+
assert local_fs.isdir(local_join(target, "subdir"))
|
| 556 |
+
assert local_fs.isfile(local_join(target, "subdir", "subfile.txt"))
|
| 557 |
+
assert local_fs.isfile(local_join(target, "subdir.txt"))
|
| 558 |
+
|
| 559 |
+
def test_get_with_source_and_destination_as_list(
|
| 560 |
+
self,
|
| 561 |
+
fs,
|
| 562 |
+
fs_join,
|
| 563 |
+
local_fs,
|
| 564 |
+
local_join,
|
| 565 |
+
local_target,
|
| 566 |
+
fs_10_files_with_hashed_names,
|
| 567 |
+
):
|
| 568 |
+
# Create the test dir
|
| 569 |
+
source = fs_10_files_with_hashed_names
|
| 570 |
+
target = local_target
|
| 571 |
+
|
| 572 |
+
# Create list of files for source and destination
|
| 573 |
+
source_files = []
|
| 574 |
+
destination_files = []
|
| 575 |
+
for i in range(10):
|
| 576 |
+
hashed_i = md5(str(i).encode("utf-8")).hexdigest()
|
| 577 |
+
source_files.append(fs_join(source, f"{hashed_i}.txt"))
|
| 578 |
+
destination_files.append(
|
| 579 |
+
make_path_posix(local_join(target, f"{hashed_i}.txt"))
|
| 580 |
+
)
|
| 581 |
+
|
| 582 |
+
# Copy and assert order was kept
|
| 583 |
+
fs.get(rpath=source_files, lpath=destination_files)
|
| 584 |
+
|
| 585 |
+
for i in range(10):
|
| 586 |
+
file_content = local_fs.cat(destination_files[i]).decode("utf-8")
|
| 587 |
+
assert file_content == str(i)
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/mv.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
import pytest
|
| 4 |
+
|
| 5 |
+
import fsspec
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def test_move_raises_error_with_tmpdir(tmpdir):
|
| 9 |
+
# Create a file in the temporary directory
|
| 10 |
+
source = tmpdir.join("source_file.txt")
|
| 11 |
+
source.write("content")
|
| 12 |
+
|
| 13 |
+
# Define a destination that simulates a protected or invalid path
|
| 14 |
+
destination = tmpdir.join("non_existent_directory/destination_file.txt")
|
| 15 |
+
|
| 16 |
+
# Instantiate the filesystem (assuming the local file system interface)
|
| 17 |
+
fs = fsspec.filesystem("file")
|
| 18 |
+
|
| 19 |
+
# Use the actual file paths as string
|
| 20 |
+
with pytest.raises(FileNotFoundError):
|
| 21 |
+
fs.mv(str(source), str(destination))
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
@pytest.mark.parametrize("recursive", (True, False))
|
| 25 |
+
def test_move_raises_error_with_tmpdir_permission(recursive, tmpdir):
|
| 26 |
+
# Create a file in the temporary directory
|
| 27 |
+
source = tmpdir.join("source_file.txt")
|
| 28 |
+
source.write("content")
|
| 29 |
+
|
| 30 |
+
# Create a protected directory (non-writable)
|
| 31 |
+
protected_dir = tmpdir.mkdir("protected_directory")
|
| 32 |
+
protected_path = str(protected_dir)
|
| 33 |
+
|
| 34 |
+
# Set the directory to read-only
|
| 35 |
+
if os.name == "nt":
|
| 36 |
+
os.system(f'icacls "{protected_path}" /deny Everyone:(W)')
|
| 37 |
+
else:
|
| 38 |
+
os.chmod(protected_path, 0o555) # Sets the directory to read-only
|
| 39 |
+
|
| 40 |
+
# Define a destination inside the protected directory
|
| 41 |
+
destination = protected_dir.join("destination_file.txt")
|
| 42 |
+
|
| 43 |
+
# Instantiate the filesystem (assuming the local file system interface)
|
| 44 |
+
fs = fsspec.filesystem("file")
|
| 45 |
+
|
| 46 |
+
# Try to move the file to the read-only directory, expecting a permission error
|
| 47 |
+
with pytest.raises(PermissionError):
|
| 48 |
+
fs.mv(str(source), str(destination), recursive=recursive)
|
| 49 |
+
|
| 50 |
+
# Assert the file was not created in the destination
|
| 51 |
+
assert not os.path.exists(destination)
|
| 52 |
+
|
| 53 |
+
# Cleanup: Restore permissions so the directory can be cleaned up
|
| 54 |
+
if os.name == "nt":
|
| 55 |
+
os.system(f'icacls "{protected_path}" /remove:d Everyone')
|
| 56 |
+
else:
|
| 57 |
+
os.chmod(protected_path, 0o755) # Restore write permission for cleanup
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/open.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class AbstractOpenTests:
|
| 5 |
+
def test_open_exclusive(self, fs, fs_target):
|
| 6 |
+
with fs.open(fs_target, "wb") as f:
|
| 7 |
+
f.write(b"data")
|
| 8 |
+
with fs.open(fs_target, "rb") as f:
|
| 9 |
+
assert f.read() == b"data"
|
| 10 |
+
with pytest.raises(FileExistsError):
|
| 11 |
+
fs.open(fs_target, "xb")
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/pipe.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class AbstractPipeTests:
|
| 5 |
+
def test_pipe_exclusive(self, fs, fs_target):
|
| 6 |
+
fs.pipe_file(fs_target, b"data")
|
| 7 |
+
assert fs.cat_file(fs_target) == b"data"
|
| 8 |
+
with pytest.raises(FileExistsError):
|
| 9 |
+
fs.pipe_file(fs_target, b"data", mode="create")
|
| 10 |
+
fs.pipe_file(fs_target, b"new data", mode="overwrite")
|
| 11 |
+
assert fs.cat_file(fs_target) == b"new data"
|
tool_server/.venv/lib/python3.12/site-packages/fsspec/tests/abstract/put.py
ADDED
|
@@ -0,0 +1,591 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from hashlib import md5
|
| 2 |
+
from itertools import product
|
| 3 |
+
|
| 4 |
+
import pytest
|
| 5 |
+
|
| 6 |
+
from fsspec.tests.abstract.common import GLOB_EDGE_CASES_TESTS
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class AbstractPutTests:
|
| 10 |
+
def test_put_file_to_existing_directory(
|
| 11 |
+
self,
|
| 12 |
+
fs,
|
| 13 |
+
fs_join,
|
| 14 |
+
fs_target,
|
| 15 |
+
local_join,
|
| 16 |
+
local_bulk_operations_scenario_0,
|
| 17 |
+
supports_empty_directories,
|
| 18 |
+
):
|
| 19 |
+
# Copy scenario 1a
|
| 20 |
+
source = local_bulk_operations_scenario_0
|
| 21 |
+
|
| 22 |
+
target = fs_target
|
| 23 |
+
fs.mkdir(target)
|
| 24 |
+
if not supports_empty_directories:
|
| 25 |
+
# Force target directory to exist by adding a dummy file
|
| 26 |
+
fs.touch(fs_join(target, "dummy"))
|
| 27 |
+
assert fs.isdir(target)
|
| 28 |
+
|
| 29 |
+
target_file2 = fs_join(target, "file2")
|
| 30 |
+
target_subfile1 = fs_join(target, "subfile1")
|
| 31 |
+
|
| 32 |
+
# Copy from source directory
|
| 33 |
+
fs.put(local_join(source, "file2"), target)
|
| 34 |
+
assert fs.isfile(target_file2)
|
| 35 |
+
|
| 36 |
+
# Copy from sub directory
|
| 37 |
+
fs.put(local_join(source, "subdir", "subfile1"), target)
|
| 38 |
+
assert fs.isfile(target_subfile1)
|
| 39 |
+
|
| 40 |
+
# Remove copied files
|
| 41 |
+
fs.rm([target_file2, target_subfile1])
|
| 42 |
+
assert not fs.exists(target_file2)
|
| 43 |
+
assert not fs.exists(target_subfile1)
|
| 44 |
+
|
| 45 |
+
# Repeat with trailing slash on target
|
| 46 |
+
fs.put(local_join(source, "file2"), target + "/")
|
| 47 |
+
assert fs.isdir(target)
|
| 48 |
+
assert fs.isfile(target_file2)
|
| 49 |
+
|
| 50 |
+
fs.put(local_join(source, "subdir", "subfile1"), target + "/")
|
| 51 |
+
assert fs.isfile(target_subfile1)
|
| 52 |
+
|
| 53 |
+
def test_put_file_to_new_directory(
|
| 54 |
+
self, fs, fs_join, fs_target, local_join, local_bulk_operations_scenario_0
|
| 55 |
+
):
|
| 56 |
+
# Copy scenario 1b
|
| 57 |
+
source = local_bulk_operations_scenario_0
|
| 58 |
+
|
| 59 |
+
target = fs_target
|
| 60 |
+
fs.mkdir(target)
|
| 61 |
+
|
| 62 |
+
fs.put(
|
| 63 |
+
local_join(source, "subdir", "subfile1"), fs_join(target, "newdir/")
|
| 64 |
+
) # Note trailing slash
|
| 65 |
+
assert fs.isdir(target)
|
| 66 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 67 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile1"))
|
| 68 |
+
|
| 69 |
+
def test_put_file_to_file_in_existing_directory(
|
| 70 |
+
self,
|
| 71 |
+
fs,
|
| 72 |
+
fs_join,
|
| 73 |
+
fs_target,
|
| 74 |
+
local_join,
|
| 75 |
+
supports_empty_directories,
|
| 76 |
+
local_bulk_operations_scenario_0,
|
| 77 |
+
):
|
| 78 |
+
# Copy scenario 1c
|
| 79 |
+
source = local_bulk_operations_scenario_0
|
| 80 |
+
|
| 81 |
+
target = fs_target
|
| 82 |
+
fs.mkdir(target)
|
| 83 |
+
if not supports_empty_directories:
|
| 84 |
+
# Force target directory to exist by adding a dummy file
|
| 85 |
+
fs.touch(fs_join(target, "dummy"))
|
| 86 |
+
assert fs.isdir(target)
|
| 87 |
+
|
| 88 |
+
fs.put(local_join(source, "subdir", "subfile1"), fs_join(target, "newfile"))
|
| 89 |
+
assert fs.isfile(fs_join(target, "newfile"))
|
| 90 |
+
|
| 91 |
+
def test_put_file_to_file_in_new_directory(
|
| 92 |
+
self, fs, fs_join, fs_target, local_join, local_bulk_operations_scenario_0
|
| 93 |
+
):
|
| 94 |
+
# Copy scenario 1d
|
| 95 |
+
source = local_bulk_operations_scenario_0
|
| 96 |
+
|
| 97 |
+
target = fs_target
|
| 98 |
+
fs.mkdir(target)
|
| 99 |
+
|
| 100 |
+
fs.put(
|
| 101 |
+
local_join(source, "subdir", "subfile1"),
|
| 102 |
+
fs_join(target, "newdir", "newfile"),
|
| 103 |
+
)
|
| 104 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 105 |
+
assert fs.isfile(fs_join(target, "newdir", "newfile"))
|
| 106 |
+
|
| 107 |
+
def test_put_directory_to_existing_directory(
|
| 108 |
+
self,
|
| 109 |
+
fs,
|
| 110 |
+
fs_join,
|
| 111 |
+
fs_target,
|
| 112 |
+
local_bulk_operations_scenario_0,
|
| 113 |
+
supports_empty_directories,
|
| 114 |
+
):
|
| 115 |
+
# Copy scenario 1e
|
| 116 |
+
source = local_bulk_operations_scenario_0
|
| 117 |
+
|
| 118 |
+
target = fs_target
|
| 119 |
+
fs.mkdir(target)
|
| 120 |
+
if not supports_empty_directories:
|
| 121 |
+
# Force target directory to exist by adding a dummy file
|
| 122 |
+
dummy = fs_join(target, "dummy")
|
| 123 |
+
fs.touch(dummy)
|
| 124 |
+
assert fs.isdir(target)
|
| 125 |
+
|
| 126 |
+
for source_slash, target_slash in zip([False, True], [False, True]):
|
| 127 |
+
s = fs_join(source, "subdir")
|
| 128 |
+
if source_slash:
|
| 129 |
+
s += "/"
|
| 130 |
+
t = target + "/" if target_slash else target
|
| 131 |
+
|
| 132 |
+
# Without recursive does nothing
|
| 133 |
+
fs.put(s, t)
|
| 134 |
+
assert fs.ls(target, detail=False) == (
|
| 135 |
+
[] if supports_empty_directories else [dummy]
|
| 136 |
+
)
|
| 137 |
+
|
| 138 |
+
# With recursive
|
| 139 |
+
fs.put(s, t, recursive=True)
|
| 140 |
+
if source_slash:
|
| 141 |
+
assert fs.isfile(fs_join(target, "subfile1"))
|
| 142 |
+
assert fs.isfile(fs_join(target, "subfile2"))
|
| 143 |
+
assert fs.isdir(fs_join(target, "nesteddir"))
|
| 144 |
+
assert fs.isfile(fs_join(target, "nesteddir", "nestedfile"))
|
| 145 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 146 |
+
|
| 147 |
+
fs.rm(
|
| 148 |
+
[
|
| 149 |
+
fs_join(target, "subfile1"),
|
| 150 |
+
fs_join(target, "subfile2"),
|
| 151 |
+
fs_join(target, "nesteddir"),
|
| 152 |
+
],
|
| 153 |
+
recursive=True,
|
| 154 |
+
)
|
| 155 |
+
else:
|
| 156 |
+
assert fs.isdir(fs_join(target, "subdir"))
|
| 157 |
+
assert fs.isfile(fs_join(target, "subdir", "subfile1"))
|
| 158 |
+
assert fs.isfile(fs_join(target, "subdir", "subfile2"))
|
| 159 |
+
assert fs.isdir(fs_join(target, "subdir", "nesteddir"))
|
| 160 |
+
assert fs.isfile(fs_join(target, "subdir", "nesteddir", "nestedfile"))
|
| 161 |
+
|
| 162 |
+
fs.rm(fs_join(target, "subdir"), recursive=True)
|
| 163 |
+
assert fs.ls(target, detail=False) == (
|
| 164 |
+
[] if supports_empty_directories else [dummy]
|
| 165 |
+
)
|
| 166 |
+
|
| 167 |
+
# Limit recursive by maxdepth
|
| 168 |
+
fs.put(s, t, recursive=True, maxdepth=1)
|
| 169 |
+
if source_slash:
|
| 170 |
+
assert fs.isfile(fs_join(target, "subfile1"))
|
| 171 |
+
assert fs.isfile(fs_join(target, "subfile2"))
|
| 172 |
+
assert not fs.exists(fs_join(target, "nesteddir"))
|
| 173 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 174 |
+
|
| 175 |
+
fs.rm(
|
| 176 |
+
[
|
| 177 |
+
fs_join(target, "subfile1"),
|
| 178 |
+
fs_join(target, "subfile2"),
|
| 179 |
+
],
|
| 180 |
+
recursive=True,
|
| 181 |
+
)
|
| 182 |
+
else:
|
| 183 |
+
assert fs.isdir(fs_join(target, "subdir"))
|
| 184 |
+
assert fs.isfile(fs_join(target, "subdir", "subfile1"))
|
| 185 |
+
assert fs.isfile(fs_join(target, "subdir", "subfile2"))
|
| 186 |
+
assert not fs.exists(fs_join(target, "subdir", "nesteddir"))
|
| 187 |
+
|
| 188 |
+
fs.rm(fs_join(target, "subdir"), recursive=True)
|
| 189 |
+
assert fs.ls(target, detail=False) == (
|
| 190 |
+
[] if supports_empty_directories else [dummy]
|
| 191 |
+
)
|
| 192 |
+
|
| 193 |
+
def test_put_directory_to_new_directory(
|
| 194 |
+
self,
|
| 195 |
+
fs,
|
| 196 |
+
fs_join,
|
| 197 |
+
fs_target,
|
| 198 |
+
local_bulk_operations_scenario_0,
|
| 199 |
+
supports_empty_directories,
|
| 200 |
+
):
|
| 201 |
+
# Copy scenario 1f
|
| 202 |
+
source = local_bulk_operations_scenario_0
|
| 203 |
+
|
| 204 |
+
target = fs_target
|
| 205 |
+
fs.mkdir(target)
|
| 206 |
+
|
| 207 |
+
for source_slash, target_slash in zip([False, True], [False, True]):
|
| 208 |
+
s = fs_join(source, "subdir")
|
| 209 |
+
if source_slash:
|
| 210 |
+
s += "/"
|
| 211 |
+
t = fs_join(target, "newdir")
|
| 212 |
+
if target_slash:
|
| 213 |
+
t += "/"
|
| 214 |
+
|
| 215 |
+
# Without recursive does nothing
|
| 216 |
+
fs.put(s, t)
|
| 217 |
+
if supports_empty_directories:
|
| 218 |
+
assert fs.ls(target) == []
|
| 219 |
+
else:
|
| 220 |
+
with pytest.raises(FileNotFoundError):
|
| 221 |
+
fs.ls(target)
|
| 222 |
+
|
| 223 |
+
# With recursive
|
| 224 |
+
fs.put(s, t, recursive=True)
|
| 225 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 226 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile1"))
|
| 227 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile2"))
|
| 228 |
+
assert fs.isdir(fs_join(target, "newdir", "nesteddir"))
|
| 229 |
+
assert fs.isfile(fs_join(target, "newdir", "nesteddir", "nestedfile"))
|
| 230 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 231 |
+
|
| 232 |
+
fs.rm(fs_join(target, "newdir"), recursive=True)
|
| 233 |
+
assert not fs.exists(fs_join(target, "newdir"))
|
| 234 |
+
|
| 235 |
+
# Limit recursive by maxdepth
|
| 236 |
+
fs.put(s, t, recursive=True, maxdepth=1)
|
| 237 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 238 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile1"))
|
| 239 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile2"))
|
| 240 |
+
assert not fs.exists(fs_join(target, "newdir", "nesteddir"))
|
| 241 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 242 |
+
|
| 243 |
+
fs.rm(fs_join(target, "newdir"), recursive=True)
|
| 244 |
+
assert not fs.exists(fs_join(target, "newdir"))
|
| 245 |
+
|
| 246 |
+
def test_put_glob_to_existing_directory(
|
| 247 |
+
self,
|
| 248 |
+
fs,
|
| 249 |
+
fs_join,
|
| 250 |
+
fs_target,
|
| 251 |
+
local_join,
|
| 252 |
+
supports_empty_directories,
|
| 253 |
+
local_bulk_operations_scenario_0,
|
| 254 |
+
):
|
| 255 |
+
# Copy scenario 1g
|
| 256 |
+
source = local_bulk_operations_scenario_0
|
| 257 |
+
|
| 258 |
+
target = fs_target
|
| 259 |
+
fs.mkdir(target)
|
| 260 |
+
if not supports_empty_directories:
|
| 261 |
+
# Force target directory to exist by adding a dummy file
|
| 262 |
+
dummy = fs_join(target, "dummy")
|
| 263 |
+
fs.touch(dummy)
|
| 264 |
+
assert fs.isdir(target)
|
| 265 |
+
|
| 266 |
+
for target_slash in [False, True]:
|
| 267 |
+
t = target + "/" if target_slash else target
|
| 268 |
+
|
| 269 |
+
# Without recursive
|
| 270 |
+
fs.put(local_join(source, "subdir", "*"), t)
|
| 271 |
+
assert fs.isfile(fs_join(target, "subfile1"))
|
| 272 |
+
assert fs.isfile(fs_join(target, "subfile2"))
|
| 273 |
+
assert not fs.isdir(fs_join(target, "nesteddir"))
|
| 274 |
+
assert not fs.exists(fs_join(target, "nesteddir", "nestedfile"))
|
| 275 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 276 |
+
|
| 277 |
+
fs.rm(
|
| 278 |
+
[
|
| 279 |
+
fs_join(target, "subfile1"),
|
| 280 |
+
fs_join(target, "subfile2"),
|
| 281 |
+
],
|
| 282 |
+
recursive=True,
|
| 283 |
+
)
|
| 284 |
+
assert fs.ls(target, detail=False) == (
|
| 285 |
+
[] if supports_empty_directories else [dummy]
|
| 286 |
+
)
|
| 287 |
+
|
| 288 |
+
# With recursive
|
| 289 |
+
for glob, recursive in zip(["*", "**"], [True, False]):
|
| 290 |
+
fs.put(local_join(source, "subdir", glob), t, recursive=recursive)
|
| 291 |
+
assert fs.isfile(fs_join(target, "subfile1"))
|
| 292 |
+
assert fs.isfile(fs_join(target, "subfile2"))
|
| 293 |
+
assert fs.isdir(fs_join(target, "nesteddir"))
|
| 294 |
+
assert fs.isfile(fs_join(target, "nesteddir", "nestedfile"))
|
| 295 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 296 |
+
|
| 297 |
+
fs.rm(
|
| 298 |
+
[
|
| 299 |
+
fs_join(target, "subfile1"),
|
| 300 |
+
fs_join(target, "subfile2"),
|
| 301 |
+
fs_join(target, "nesteddir"),
|
| 302 |
+
],
|
| 303 |
+
recursive=True,
|
| 304 |
+
)
|
| 305 |
+
assert fs.ls(target, detail=False) == (
|
| 306 |
+
[] if supports_empty_directories else [dummy]
|
| 307 |
+
)
|
| 308 |
+
|
| 309 |
+
# Limit recursive by maxdepth
|
| 310 |
+
fs.put(
|
| 311 |
+
local_join(source, "subdir", glob),
|
| 312 |
+
t,
|
| 313 |
+
recursive=recursive,
|
| 314 |
+
maxdepth=1,
|
| 315 |
+
)
|
| 316 |
+
assert fs.isfile(fs_join(target, "subfile1"))
|
| 317 |
+
assert fs.isfile(fs_join(target, "subfile2"))
|
| 318 |
+
assert not fs.exists(fs_join(target, "nesteddir"))
|
| 319 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 320 |
+
|
| 321 |
+
fs.rm(
|
| 322 |
+
[
|
| 323 |
+
fs_join(target, "subfile1"),
|
| 324 |
+
fs_join(target, "subfile2"),
|
| 325 |
+
],
|
| 326 |
+
recursive=True,
|
| 327 |
+
)
|
| 328 |
+
assert fs.ls(target, detail=False) == (
|
| 329 |
+
[] if supports_empty_directories else [dummy]
|
| 330 |
+
)
|
| 331 |
+
|
| 332 |
+
def test_put_glob_to_new_directory(
|
| 333 |
+
self, fs, fs_join, fs_target, local_join, local_bulk_operations_scenario_0
|
| 334 |
+
):
|
| 335 |
+
# Copy scenario 1h
|
| 336 |
+
source = local_bulk_operations_scenario_0
|
| 337 |
+
|
| 338 |
+
target = fs_target
|
| 339 |
+
fs.mkdir(target)
|
| 340 |
+
|
| 341 |
+
for target_slash in [False, True]:
|
| 342 |
+
t = fs_join(target, "newdir")
|
| 343 |
+
if target_slash:
|
| 344 |
+
t += "/"
|
| 345 |
+
|
| 346 |
+
# Without recursive
|
| 347 |
+
fs.put(local_join(source, "subdir", "*"), t)
|
| 348 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 349 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile1"))
|
| 350 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile2"))
|
| 351 |
+
assert not fs.exists(fs_join(target, "newdir", "nesteddir"))
|
| 352 |
+
assert not fs.exists(fs_join(target, "newdir", "nesteddir", "nestedfile"))
|
| 353 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 354 |
+
assert not fs.exists(fs_join(target, "newdir", "subdir"))
|
| 355 |
+
|
| 356 |
+
fs.rm(fs_join(target, "newdir"), recursive=True)
|
| 357 |
+
assert not fs.exists(fs_join(target, "newdir"))
|
| 358 |
+
|
| 359 |
+
# With recursive
|
| 360 |
+
for glob, recursive in zip(["*", "**"], [True, False]):
|
| 361 |
+
fs.put(local_join(source, "subdir", glob), t, recursive=recursive)
|
| 362 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 363 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile1"))
|
| 364 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile2"))
|
| 365 |
+
assert fs.isdir(fs_join(target, "newdir", "nesteddir"))
|
| 366 |
+
assert fs.isfile(fs_join(target, "newdir", "nesteddir", "nestedfile"))
|
| 367 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 368 |
+
assert not fs.exists(fs_join(target, "newdir", "subdir"))
|
| 369 |
+
|
| 370 |
+
fs.rm(fs_join(target, "newdir"), recursive=True)
|
| 371 |
+
assert not fs.exists(fs_join(target, "newdir"))
|
| 372 |
+
|
| 373 |
+
# Limit recursive by maxdepth
|
| 374 |
+
fs.put(
|
| 375 |
+
local_join(source, "subdir", glob),
|
| 376 |
+
t,
|
| 377 |
+
recursive=recursive,
|
| 378 |
+
maxdepth=1,
|
| 379 |
+
)
|
| 380 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 381 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile1"))
|
| 382 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile2"))
|
| 383 |
+
assert not fs.exists(fs_join(target, "newdir", "nesteddir"))
|
| 384 |
+
assert not fs.exists(fs_join(target, "subdir"))
|
| 385 |
+
assert not fs.exists(fs_join(target, "newdir", "subdir"))
|
| 386 |
+
|
| 387 |
+
fs.rm(fs_join(target, "newdir"), recursive=True)
|
| 388 |
+
assert not fs.exists(fs_join(target, "newdir"))
|
| 389 |
+
|
| 390 |
+
@pytest.mark.parametrize(
|
| 391 |
+
GLOB_EDGE_CASES_TESTS["argnames"],
|
| 392 |
+
GLOB_EDGE_CASES_TESTS["argvalues"],
|
| 393 |
+
)
|
| 394 |
+
def test_put_glob_edge_cases(
|
| 395 |
+
self,
|
| 396 |
+
path,
|
| 397 |
+
recursive,
|
| 398 |
+
maxdepth,
|
| 399 |
+
expected,
|
| 400 |
+
fs,
|
| 401 |
+
fs_join,
|
| 402 |
+
fs_target,
|
| 403 |
+
local_glob_edge_cases_files,
|
| 404 |
+
local_join,
|
| 405 |
+
fs_sanitize_path,
|
| 406 |
+
):
|
| 407 |
+
# Copy scenario 1g
|
| 408 |
+
source = local_glob_edge_cases_files
|
| 409 |
+
|
| 410 |
+
target = fs_target
|
| 411 |
+
|
| 412 |
+
for new_dir, target_slash in product([True, False], [True, False]):
|
| 413 |
+
fs.mkdir(target)
|
| 414 |
+
|
| 415 |
+
t = fs_join(target, "newdir") if new_dir else target
|
| 416 |
+
t = t + "/" if target_slash else t
|
| 417 |
+
|
| 418 |
+
fs.put(local_join(source, path), t, recursive=recursive, maxdepth=maxdepth)
|
| 419 |
+
|
| 420 |
+
output = fs.find(target)
|
| 421 |
+
if new_dir:
|
| 422 |
+
prefixed_expected = [
|
| 423 |
+
fs_sanitize_path(fs_join(target, "newdir", p)) for p in expected
|
| 424 |
+
]
|
| 425 |
+
else:
|
| 426 |
+
prefixed_expected = [
|
| 427 |
+
fs_sanitize_path(fs_join(target, p)) for p in expected
|
| 428 |
+
]
|
| 429 |
+
assert sorted(output) == sorted(prefixed_expected)
|
| 430 |
+
|
| 431 |
+
try:
|
| 432 |
+
fs.rm(target, recursive=True)
|
| 433 |
+
except FileNotFoundError:
|
| 434 |
+
pass
|
| 435 |
+
|
| 436 |
+
def test_put_list_of_files_to_existing_directory(
|
| 437 |
+
self,
|
| 438 |
+
fs,
|
| 439 |
+
fs_join,
|
| 440 |
+
fs_target,
|
| 441 |
+
local_join,
|
| 442 |
+
local_bulk_operations_scenario_0,
|
| 443 |
+
supports_empty_directories,
|
| 444 |
+
):
|
| 445 |
+
# Copy scenario 2a
|
| 446 |
+
source = local_bulk_operations_scenario_0
|
| 447 |
+
|
| 448 |
+
target = fs_target
|
| 449 |
+
fs.mkdir(target)
|
| 450 |
+
if not supports_empty_directories:
|
| 451 |
+
# Force target directory to exist by adding a dummy file
|
| 452 |
+
dummy = fs_join(target, "dummy")
|
| 453 |
+
fs.touch(dummy)
|
| 454 |
+
assert fs.isdir(target)
|
| 455 |
+
|
| 456 |
+
source_files = [
|
| 457 |
+
local_join(source, "file1"),
|
| 458 |
+
local_join(source, "file2"),
|
| 459 |
+
local_join(source, "subdir", "subfile1"),
|
| 460 |
+
]
|
| 461 |
+
|
| 462 |
+
for target_slash in [False, True]:
|
| 463 |
+
t = target + "/" if target_slash else target
|
| 464 |
+
|
| 465 |
+
fs.put(source_files, t)
|
| 466 |
+
assert fs.isfile(fs_join(target, "file1"))
|
| 467 |
+
assert fs.isfile(fs_join(target, "file2"))
|
| 468 |
+
assert fs.isfile(fs_join(target, "subfile1"))
|
| 469 |
+
|
| 470 |
+
fs.rm(
|
| 471 |
+
[
|
| 472 |
+
fs_join(target, "file1"),
|
| 473 |
+
fs_join(target, "file2"),
|
| 474 |
+
fs_join(target, "subfile1"),
|
| 475 |
+
],
|
| 476 |
+
recursive=True,
|
| 477 |
+
)
|
| 478 |
+
assert fs.ls(target, detail=False) == (
|
| 479 |
+
[] if supports_empty_directories else [dummy]
|
| 480 |
+
)
|
| 481 |
+
|
| 482 |
+
def test_put_list_of_files_to_new_directory(
|
| 483 |
+
self, fs, fs_join, fs_target, local_join, local_bulk_operations_scenario_0
|
| 484 |
+
):
|
| 485 |
+
# Copy scenario 2b
|
| 486 |
+
source = local_bulk_operations_scenario_0
|
| 487 |
+
|
| 488 |
+
target = fs_target
|
| 489 |
+
fs.mkdir(target)
|
| 490 |
+
|
| 491 |
+
source_files = [
|
| 492 |
+
local_join(source, "file1"),
|
| 493 |
+
local_join(source, "file2"),
|
| 494 |
+
local_join(source, "subdir", "subfile1"),
|
| 495 |
+
]
|
| 496 |
+
|
| 497 |
+
fs.put(source_files, fs_join(target, "newdir") + "/") # Note trailing slash
|
| 498 |
+
assert fs.isdir(fs_join(target, "newdir"))
|
| 499 |
+
assert fs.isfile(fs_join(target, "newdir", "file1"))
|
| 500 |
+
assert fs.isfile(fs_join(target, "newdir", "file2"))
|
| 501 |
+
assert fs.isfile(fs_join(target, "newdir", "subfile1"))
|
| 502 |
+
|
| 503 |
+
def test_put_directory_recursive(
|
| 504 |
+
self, fs, fs_join, fs_target, local_fs, local_join, local_path
|
| 505 |
+
):
|
| 506 |
+
# https://github.com/fsspec/filesystem_spec/issues/1062
|
| 507 |
+
# Recursive cp/get/put of source directory into non-existent target directory.
|
| 508 |
+
src = local_join(local_path, "src")
|
| 509 |
+
src_file = local_join(src, "file")
|
| 510 |
+
local_fs.mkdir(src)
|
| 511 |
+
local_fs.touch(src_file)
|
| 512 |
+
|
| 513 |
+
target = fs_target
|
| 514 |
+
|
| 515 |
+
# put without slash
|
| 516 |
+
assert not fs.exists(target)
|
| 517 |
+
for loop in range(2):
|
| 518 |
+
fs.put(src, target, recursive=True)
|
| 519 |
+
assert fs.isdir(target)
|
| 520 |
+
|
| 521 |
+
if loop == 0:
|
| 522 |
+
assert fs.isfile(fs_join(target, "file"))
|
| 523 |
+
assert not fs.exists(fs_join(target, "src"))
|
| 524 |
+
else:
|
| 525 |
+
assert fs.isfile(fs_join(target, "file"))
|
| 526 |
+
assert fs.isdir(fs_join(target, "src"))
|
| 527 |
+
assert fs.isfile(fs_join(target, "src", "file"))
|
| 528 |
+
|
| 529 |
+
fs.rm(target, recursive=True)
|
| 530 |
+
|
| 531 |
+
# put with slash
|
| 532 |
+
assert not fs.exists(target)
|
| 533 |
+
for loop in range(2):
|
| 534 |
+
fs.put(src + "/", target, recursive=True)
|
| 535 |
+
assert fs.isdir(target)
|
| 536 |
+
assert fs.isfile(fs_join(target, "file"))
|
| 537 |
+
assert not fs.exists(fs_join(target, "src"))
|
| 538 |
+
|
| 539 |
+
def test_put_directory_without_files_with_same_name_prefix(
|
| 540 |
+
self,
|
| 541 |
+
fs,
|
| 542 |
+
fs_join,
|
| 543 |
+
fs_target,
|
| 544 |
+
local_join,
|
| 545 |
+
local_dir_and_file_with_same_name_prefix,
|
| 546 |
+
supports_empty_directories,
|
| 547 |
+
):
|
| 548 |
+
# Create the test dirs
|
| 549 |
+
source = local_dir_and_file_with_same_name_prefix
|
| 550 |
+
target = fs_target
|
| 551 |
+
|
| 552 |
+
# Test without glob
|
| 553 |
+
fs.put(local_join(source, "subdir"), fs_target, recursive=True)
|
| 554 |
+
|
| 555 |
+
assert fs.isfile(fs_join(fs_target, "subfile.txt"))
|
| 556 |
+
assert not fs.isfile(fs_join(fs_target, "subdir.txt"))
|
| 557 |
+
|
| 558 |
+
fs.rm([fs_join(target, "subfile.txt")])
|
| 559 |
+
if supports_empty_directories:
|
| 560 |
+
assert fs.ls(target) == []
|
| 561 |
+
else:
|
| 562 |
+
assert not fs.exists(target)
|
| 563 |
+
|
| 564 |
+
# Test with glob
|
| 565 |
+
fs.put(local_join(source, "subdir*"), fs_target, recursive=True)
|
| 566 |
+
|
| 567 |
+
assert fs.isdir(fs_join(fs_target, "subdir"))
|
| 568 |
+
assert fs.isfile(fs_join(fs_target, "subdir", "subfile.txt"))
|
| 569 |
+
assert fs.isfile(fs_join(fs_target, "subdir.txt"))
|
| 570 |
+
|
| 571 |
+
def test_copy_with_source_and_destination_as_list(
|
| 572 |
+
self, fs, fs_target, fs_join, local_join, local_10_files_with_hashed_names
|
| 573 |
+
):
|
| 574 |
+
# Create the test dir
|
| 575 |
+
source = local_10_files_with_hashed_names
|
| 576 |
+
target = fs_target
|
| 577 |
+
|
| 578 |
+
# Create list of files for source and destination
|
| 579 |
+
source_files = []
|
| 580 |
+
destination_files = []
|
| 581 |
+
for i in range(10):
|
| 582 |
+
hashed_i = md5(str(i).encode("utf-8")).hexdigest()
|
| 583 |
+
source_files.append(local_join(source, f"{hashed_i}.txt"))
|
| 584 |
+
destination_files.append(fs_join(target, f"{hashed_i}.txt"))
|
| 585 |
+
|
| 586 |
+
# Copy and assert order was kept
|
| 587 |
+
fs.put(lpath=source_files, rpath=destination_files)
|
| 588 |
+
|
| 589 |
+
for i in range(10):
|
| 590 |
+
file_content = fs.cat(destination_files[i]).decode("utf-8")
|
| 591 |
+
assert file_content == str(i)
|