Skip to content

Commit

Permalink
Merge pull request #3 from jina-ai/fix-workspace
Browse files Browse the repository at this point in the history
fix: workspace update
  • Loading branch information
deepankarm authored Aug 22, 2023
2 parents 830cf06 + 8f48eec commit cf702fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
5 changes: 5 additions & 0 deletions fastapi_serve/cloud/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import platform as p
import secrets
import sys
from http import HTTPStatus
Expand Down Expand Up @@ -244,6 +245,10 @@ def push_app_to_hubble(
tmpdir = mkdtemp()
app_dir, _ = get_app_dir(app=app, app_dir=app_dir)

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

# Copy appdir to tmpdir
copytree(app_dir, tmpdir, dirs_exist_ok=True)
# Copy fastapi_serve to tmpdir
Expand Down
17 changes: 2 additions & 15 deletions fastapi_serve/gateway/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,9 @@ def __init__(self, app: str, *args, **kwargs):
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

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 '/data/workspace'

def _init_fastapi_app(self):
with EnvironmentVarCtxtManager({'JCLOUD_WORKSPACE': self.workspace}):
Expand Down

0 comments on commit cf702fd

Please sign in to comment.