lamindb_setup 0.69.4__py2.py3-none-any.whl → 0.69.5__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
lamindb_setup/__init__.py CHANGED
@@ -36,7 +36,7 @@ Modules & settings:
36
36
 
37
37
  """
38
38
 
39
- __version__ = "0.69.4" # denote a release candidate for 0.1.0 with 0.1rc1
39
+ __version__ = "0.69.5" # denote a release candidate for 0.1.0 with 0.1rc1
40
40
 
41
41
  import sys
42
42
  from os import name as _os_name
@@ -165,7 +165,7 @@ class ProgressCallback(fsspec.callbacks.Callback):
165
165
  return None
166
166
 
167
167
 
168
- def download_to(self, path, print_progress: bool = False, **kwargs):
168
+ def download_to(self, path: UPathStr, print_progress: bool = False, **kwargs):
169
169
  """Download to a path."""
170
170
  if print_progress:
171
171
  # can't do path.is_dir() because path doesn't exist
@@ -180,20 +180,38 @@ def download_to(self, path, print_progress: bool = False, **kwargs):
180
180
  self.fs.download(str(self), str(path), **kwargs)
181
181
 
182
182
 
183
- def upload_from(self, path, print_progress: bool = False, **kwargs):
183
+ def upload_from(
184
+ self,
185
+ path: UPathStr,
186
+ dir_inplace: bool = False,
187
+ print_progress: bool = False,
188
+ **kwargs,
189
+ ):
184
190
  """Upload from a local path."""
191
+ path_is_dir = os.path.isdir(path)
192
+ if not path_is_dir:
193
+ dir_inplace = False
194
+
185
195
  if print_progress:
186
- if not os.path.isdir(path):
196
+ if not path_is_dir:
187
197
  cb = ProgressCallback("uploading")
188
198
  else:
189
199
  # todo: make proper progress bar for directories
190
200
  cb = fsspec.callbacks.NoOpCallback()
191
201
  kwargs["callback"] = cb
202
+
203
+ if dir_inplace:
204
+ path = Path(path)
205
+ source = [f for f in path.rglob("*") if f.is_file()]
206
+ destination = [str(self / f.relative_to(path)) for f in source]
207
+ source = [str(f) for f in source] # type: ignore
208
+ else:
209
+ source = str(path) # type: ignore
210
+ destination = str(self) # type: ignore
192
211
  # this weird thing is to avoid s3fs triggering create_bucket in upload
193
212
  # if dirs are present
194
213
  # it allows to avoid permission error
195
- destination = str(self)
196
- if self.protocol != "s3" or os.path.isfile(path):
214
+ if self.protocol != "s3" or not path_is_dir or dir_inplace:
197
215
  cleanup_cache = False
198
216
  else:
199
217
  bucket = self._url.netloc
@@ -205,7 +223,7 @@ def upload_from(self, path, print_progress: bool = False, **kwargs):
205
223
  else:
206
224
  cleanup_cache = False
207
225
 
208
- self.fs.upload(str(path), destination, **kwargs)
226
+ self.fs.upload(source, destination, **kwargs)
209
227
 
210
228
  if cleanup_cache:
211
229
  # normally this is invalidated after the upload but still better to check
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lamindb_setup
3
- Version: 0.69.4
3
+ Version: 0.69.5
4
4
  Summary: Setup & configure LaminDB.
5
5
  Author-email: Lamin Labs <laminlabs@gmail.com>
6
6
  Description-Content-Type: text/markdown
@@ -1,4 +1,4 @@
1
- lamindb_setup/__init__.py,sha256=0WvssKET9TeGkrbvOxtdFPzn4cpVXtv8JyRR4eGz7qU,1558
1
+ lamindb_setup/__init__.py,sha256=UtfzeMDIIg5wzz8ahXKmjc2p9pgSXvoXop6PeSM3fig,1558
2
2
  lamindb_setup/_add_remote_storage.py,sha256=S2rFvn-JcGaBOiBNQoAiaTPM590GQh-g4OJeNsben0Q,1802
3
3
  lamindb_setup/_cache.py,sha256=wrwlHi2IfxcWDfOW-cHzzkQNlLvasoQPPNxihICbwew,809
4
4
  lamindb_setup/_check.py,sha256=xgc5kF2HA4lGuAA9FJT9BJyQV5z1EwYMr92RTbGcQg4,92
@@ -36,8 +36,8 @@ lamindb_setup/core/django.py,sha256=MNlEFS8a7GX1IxmMgJymoRf3M03Eg881zQ2_MKONOQI,
36
36
  lamindb_setup/core/exceptions.py,sha256=YzkJA51ZAa2w9lawAggSdg-NA-EIYJGNRnFd0DN3_bE,275
37
37
  lamindb_setup/core/hashing.py,sha256=nbQO_CSiX09O4bznHABft94fdFZAHPm2NIyvH5xagoo,2011
38
38
  lamindb_setup/core/types.py,sha256=fR71SLjoN1MkCjx8TJcjYDgmgO4bPXBX5J_RKpmmy_o,497
39
- lamindb_setup/core/upath.py,sha256=ahyWAQQfZRmtQBz-p_UN7R-wqsti6YZ8ZMixy-n8XlQ,24039
40
- lamindb_setup-0.69.4.dist-info/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
41
- lamindb_setup-0.69.4.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
42
- lamindb_setup-0.69.4.dist-info/METADATA,sha256=HKUfuOqFrwnVrQmc-wDO3_5rc4DNJMEu25L2BjPPKbo,1469
43
- lamindb_setup-0.69.4.dist-info/RECORD,,
39
+ lamindb_setup/core/upath.py,sha256=rK1GvW_-23gE5Wr3VmAv1hw4PZCxN878P-EUxXr0RlM,24510
40
+ lamindb_setup-0.69.5.dist-info/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
41
+ lamindb_setup-0.69.5.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
42
+ lamindb_setup-0.69.5.dist-info/METADATA,sha256=o7IyD1LbQF4cqks-lrF4XgOh25jZcnYkrV0o9JU_9Jo,1469
43
+ lamindb_setup-0.69.5.dist-info/RECORD,,