Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

fix: workspace path update #140

Merged
merged 1 commit into from
Aug 22, 2023
Merged
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
16 changes: 4 additions & 12 deletions lcserve/backend/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,22 +304,14 @@ def __init__(
def app(self) -> 'FastAPI':
return self._app

@cached_property
@property
def workspace(self) -> str:
import tempfile

_temp_dir = tempfile.mkdtemp()
if 'FLOW_ID' not in os.environ:
self.logger.debug(f'Using temporary workspace directory: {_temp_dir}')
return _temp_dir
if os.path.exists('/data/workspace'):
return '/data/workspace'

try:
flow_id = os.environ['FLOW_ID']
namespace = flow_id.split('-')[-1]
return os.path.join('/data', f'jnamespace-{namespace}')
except Exception as e:
self.logger.warning(f'Failed to get workspace directory: {e}')
return _temp_dir
return tempfile.mkdtemp()

def _init_fastapi_app(self):
from fastapi import FastAPI
Expand Down
5 changes: 5 additions & 0 deletions lcserve/flow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import inspect
import os
import platform as p
import secrets
import shutil
import sys
Expand Down Expand Up @@ -352,6 +353,10 @@ def push_app_to_hubble(

tmpdir = mkdtemp()

# Auto convert platform to amd64 if this is Mac
if p.machine() == 'arm64':
platform = "linux/amd64"

# Copy appdir to tmpdir
copytree(module_dir, tmpdir, dirs_exist_ok=True)
# Copy lcserve to tmpdir
Expand Down
Loading