Skip to content

Commit

Permalink
use posixpath in upload methods (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon authored Jan 24, 2025
1 parent 669f359 commit 13e5c13
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/datachain/client/fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import multiprocessing
import os
import posixpath
import re
import sys
from abc import ABC, abstractmethod
Expand Down Expand Up @@ -391,7 +392,7 @@ def open_object(
def upload(self, path: str, data: bytes) -> "File":
full_path = self.get_full_path(path)

parent = "/".join(full_path.split("/")[:-1])
parent = posixpath.dirname(full_path)
self.fs.makedirs(parent, exist_ok=True)

self.fs.pipe_file(full_path, data)
Expand Down
4 changes: 1 addition & 3 deletions src/datachain/lib/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ def upload(

catalog = get_catalog()

parts = path.split("/")
parent = "/".join(parts[:-1])
name = parts[-1]
parent, name = posixpath.split(path)

client = catalog.get_client(parent)
file = client.upload(name, data)
Expand Down

0 comments on commit 13e5c13

Please sign in to comment.