Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update docker folder fixture #1146

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion runhouse/servers/http/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,10 @@ def folder_put(
mode: str,
serialization: str,
):
serialization = serialization or "pickle"
folder_params = FolderPutParams(
path=path,
contents=contents,
contents=serialize_data(contents, serialization),
mode=mode,
overwrite=overwrite,
serialization=serialization,
Expand Down
9 changes: 7 additions & 2 deletions runhouse/servers/http/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
resolve_folder_path,
Response,
serialize_data,
deserialize_data,
ServerSettings,
)
from runhouse.servers.obj_store import (
Expand Down Expand Up @@ -677,12 +678,16 @@ async def folder_get_cmd(request: Request, get_params: FolderGetParams):
async def folder_put_cmd(request: Request, put_params: FolderPutParams):
try:
path = resolve_folder_path(put_params.path)
serialization = put_params.serialization or "pickle"
serialized_contents = put_params.contents
contents = deserialize_data(serialized_contents, serialization)

return folder_put(
path,
contents=put_params.contents,
contents=contents,
overwrite=put_params.overwrite,
mode=put_params.mode,
serialization=put_params.serialization,
serialization=serialization,
)

except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion runhouse/servers/http/http_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class FolderGetParams(FolderParams):


class FolderPutParams(FolderParams):
contents: Optional[Any]
contents: Any
overwrite: Optional[bool] = False
mode: Optional[str] = None
serialization: Optional[str] = None
Expand Down
24 changes: 7 additions & 17 deletions tests/fixtures/folder_fixtures.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from pathlib import Path

import pytest

import runhouse as rh
from runhouse.constants import TEST_ORG

from tests.conftest import init_args

Expand Down Expand Up @@ -37,25 +34,18 @@ def local_folder():

@pytest.fixture
def docker_cluster_folder(docker_cluster_pk_ssh_no_auth):
local_path = Path.cwd()
dest_path = "rh-folder"

args = {
"name": f"/{TEST_ORG}/test_docker_folder",
"path": local_path,
"name": "test_docker_folder",
"system": docker_cluster_pk_ssh_no_auth,
"path": "rh-folder",
}

# Create a local folder based on the current working dir, then send it to the docker cluster as a module
docker_folder = rh.folder(**args).to(
system=docker_cluster_pk_ssh_no_auth, path=dest_path
)
assert docker_folder.system == docker_cluster_pk_ssh_no_auth

init_args[id(docker_folder)] = args
docker_folder.put(
local_folder_docker = rh.folder(**args)
init_args[id(local_folder_docker)] = args
local_folder_docker.put(
{f"sample_file_{i}.txt": f"file{i}".encode() for i in range(3)}, overwrite=True
)
return docker_folder
return local_folder_docker


@pytest.fixture
Expand Down
Loading