Skip to content

Commit b970e2c

Browse files
committed
Implement write_local_file with opendal
1 parent 60d1173 commit b970e2c

File tree

3 files changed

+3
-16
lines changed

3 files changed

+3
-16
lines changed

jumpstarter/drivers/mixins.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
from anyio import create_unix_listener
1313
from anyio.from_thread import BlockingPortal
14-
from anyio.streams.file import FileReadStream
1514
from opendal import Operator
1615
from pexpect.fdpexpect import fdspawn
1716

@@ -70,20 +69,6 @@ def expect(self):
7069
class ResourceMixin:
7170
"""Resource"""
7271

73-
@contextmanager
74-
def local_file(
75-
self,
76-
filepath,
77-
):
78-
"""
79-
Share local file with driver
80-
81-
:param str filepath: path to file
82-
"""
83-
with self.portal.wrap_async_context_manager(self.portal.call(FileReadStream.from_path, filepath)) as file:
84-
with self.portal.wrap_async_context_manager(self.resource_async(file)) as uuid:
85-
yield uuid
86-
8772
@contextmanager
8873
def file(self, operator: Operator, path: str):
8974
with self.portal.wrap_async_context_manager(self.file_async(operator.to_async_operator(), path)) as uuid:

jumpstarter/drivers/storage/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def write_file(self, operator: Operator, path: str):
4545
return self.call("write", handle)
4646

4747
def write_local_file(self, filepath):
48-
with self.local_file(filepath) as handle:
48+
with self.file(Operator("fs", root="/"), filepath) as handle:
4949
return self.call("write", handle)
5050

5151
def cli(self):

jumpstarter/drivers/storage/base_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from pathlib import Path
12
from tempfile import TemporaryDirectory
23

34
import pytest
@@ -15,6 +16,7 @@ def test_drivers_mock_storage_mux_fs():
1516
fs.write("test", b"testcontent" * 1000)
1617

1718
client.write_file(fs, "test")
19+
client.write_local_file(str(Path(tempdir) / "test"))
1820

1921

2022
@pytest.mark.skip(reason="require minio")

0 commit comments

Comments
 (0)