Skip to content

Commit

Permalink
File upload (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
dreadatour committed Dec 28, 2024
1 parent cf05881 commit efe4850
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/datachain/client/fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,18 @@ def open_object(
assert not file.location
return FileWrapper(self.fs.open(self.get_full_path(file.path)), cb) # type: ignore[return-value]

def upload(
self,
path: str,
data: bytes,
) -> "File":
full_path = self.get_full_path(path)
self.fs.write_bytes(full_path, data)
file_info = self.fs.info(full_path)
file = self.info_to_file(file_info, path)
self.put_in_cache(file)
return file

Check warning on line 377 in src/datachain/client/fsspec.py

View check run for this annotation

Codecov / codecov/patch

src/datachain/client/fsspec.py#L372-L377

Added lines #L372 - L377 were not covered by tests

def download(self, file: "File", *, callback: Callback = DEFAULT_CALLBACK) -> None:
sync(get_loop(), functools.partial(self._download, file, callback=callback))

Expand Down

0 comments on commit efe4850

Please sign in to comment.