Develop #16

Merged
tao.chen merged 273 commits from develop into main 2026-08-21 10:42:09 +08:00
Showing only changes of commit 3094a47298 - Show all commits
+30 -16
View File
@@ -424,14 +424,21 @@ async def create_script_record(
workspace_id = context.workspace.workspace_id workspace_id = context.workspace.workspace_id
content_hash = hashlib.sha256(content).hexdigest() content_hash = hashlib.sha256(content).hexdigest()
size_bytes = len(content) size_bytes = len(content)
if parent_ulid: # Jupyter Contents API PUT does not create intermediate directories.
try: # Make sure the user's own subfolder exists at the Jupyter level before
await runtime_client.ensure_directory(workspace_id, f"{user_id}/{parent_ulid}") # we try to write into it; on nested creates, also ensure the parent
except RuntimeClientError as exc: # directory under it. ensure_directory is idempotent (GET-first pattern).
raise HTTPException( try:
status_code=exc.status_code, await runtime_client.ensure_directory(workspace_id, user_id)
detail=exc.detail, if parent_ulid:
) from exc await runtime_client.ensure_directory(
workspace_id, f"{user_id}/{parent_ulid}"
)
except RuntimeClientError as exc:
raise HTTPException(
status_code=exc.status_code,
detail=exc.detail,
) from exc
try: try:
if script_type == "notebook": if script_type == "notebook":
@@ -826,14 +833,21 @@ async def create_workspace_directory(
runtime_client = request.app.state.runtime_client runtime_client = request.app.state.runtime_client
workspace_id = context.workspace.workspace_id workspace_id = context.workspace.workspace_id
if parent_ulid: # Jupyter Contents API PUT does not create intermediate directories.
try: # Make sure the user's own subfolder exists at the Jupyter level before
await runtime_client.ensure_directory(workspace_id, f"{user_id}/{parent_ulid}") # we try to write into it; on nested creates, also ensure the parent
except RuntimeClientError as exc: # directory under it. ensure_directory is idempotent (GET-first pattern).
raise HTTPException( try:
status_code=exc.status_code, await runtime_client.ensure_directory(workspace_id, user_id)
detail=exc.detail, if parent_ulid:
) from exc await runtime_client.ensure_directory(
workspace_id, f"{user_id}/{parent_ulid}"
)
except RuntimeClientError as exc:
raise HTTPException(
status_code=exc.status_code,
detail=exc.detail,
) from exc
try: try:
await runtime_client.create_directory(workspace_id, name=jupyter_path) await runtime_client.create_directory(workspace_id, name=jupyter_path)