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

Commit

Permalink
Merge pull request #140 from jina-ai/fix-workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
zac-li committed Aug 22, 2023
2 parents 83afd27 + 2d392b7 commit 2362bdc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
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

0 comments on commit 2362bdc

Please sign in to comment.