Skip to content

Commit

Permalink
Merge branch 'cluster-folder-methods' into use-cluster-folder-apis
Browse files Browse the repository at this point in the history
  • Loading branch information
jlewitt1 committed Aug 12, 2024
2 parents ebb8cd7 + 88e36d7 commit 8da11fe
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
14 changes: 2 additions & 12 deletions runhouse/servers/http/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,9 @@ async def wrapper(*args, **kwargs):

func_call: bool = func.__name__ in ["post_call", "get_call"]

# restrict access for folder APIs
# restrict access for folder specific APIs
access_level_required = (
ResourceAccess.WRITE
if func.__name__
in [
"folder_ls_cmd",
"folder_mkdir_cmd",
"folder_get_cmd",
"folder_put_cmd",
"folder_rm_cmd",
"folder_mv_cmd",
]
else None
ResourceAccess.WRITE if func.__name__.startswith("folder") else None
)
token = get_token_from_request(request)

Expand Down
5 changes: 4 additions & 1 deletion runhouse/servers/http/http_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,10 @@ def folder_put(
with open(file_path, mode) as f:
f.write(file_obj)
except Exception as e:
HTTPException(status_code=500, detail=f"Failed to write file: {str(e)}")
HTTPException(
status_code=500,
detail=f"Failed to write file with mode '{mode}': {str(e)}",
)

return Response(output_type=OutputType.SUCCESS)

Expand Down
1 change: 1 addition & 0 deletions runhouse/servers/http/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World!
6 changes: 2 additions & 4 deletions tests/test_resources/test_clusters/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,17 +939,15 @@ def test_cluster_mkdir_mv_and_rm(self, cluster):
assert "new-folder" in [os.path.basename(f) for f in file_contents]

# Should not be able to mv to an existing directory if `overwrite=False`
with pytest.raises(FileExistsError):
with pytest.raises(Exception):
cluster._folder_mv(
path="~/.rh/new-folder", dest_path="~/new-folder", overwrite=False
)

cluster._folder_mv(path="~/.rh/new-folder", dest_path="~/new-folder")

# Delete folder contents and directory itself
cluster._folder_rm(path="~/new-folder", recursive=True)

assert not cluster._exists(path="~/new-folder")
assert not cluster._folder_exists(path="~/new-folder")

@pytest.mark.level("release")
@pytest.mark.clustertest
Expand Down

0 comments on commit 8da11fe

Please sign in to comment.