From 13e5c130fa5998ea64c934070ba8a062c2941b0f Mon Sep 17 00:00:00 2001 From: Matt Seddon <37993418+mattseddon@users.noreply.github.com> Date: Fri, 24 Jan 2025 14:43:15 +1100 Subject: [PATCH] use posixpath in upload methods (#855) --- src/datachain/client/fsspec.py | 3 ++- src/datachain/lib/file.py | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/datachain/client/fsspec.py b/src/datachain/client/fsspec.py index 5ead774f4..f9362b1de 100644 --- a/src/datachain/client/fsspec.py +++ b/src/datachain/client/fsspec.py @@ -3,6 +3,7 @@ import logging import multiprocessing import os +import posixpath import re import sys from abc import ABC, abstractmethod @@ -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) diff --git a/src/datachain/lib/file.py b/src/datachain/lib/file.py index 3a2982c69..66c0b38db 100644 --- a/src/datachain/lib/file.py +++ b/src/datachain/lib/file.py @@ -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)