Code0ut commited on
Commit
5d215eb
·
verified ·
1 Parent(s): 3ebaddd

Upload folder using huggingface_hub

Browse files
Dockerfile CHANGED
@@ -20,10 +20,6 @@ RUN apt-get update && \
20
  apt-get install -y --no-install-recommends git && \
21
  rm -rf /var/lib/apt/lists/*
22
 
23
- # Build argument to control whether we're building standalone or in-repo
24
- ARG BUILD_MODE=in-repo
25
- ARG ENV_NAME=finenv
26
-
27
  # Copy environment code (always at root of build context)
28
  COPY . /app/env
29
 
@@ -38,21 +34,11 @@ RUN if ! command -v uv >/dev/null 2>&1; then \
38
  mv /root/.local/bin/uvx /usr/local/bin/uvx; \
39
  fi
40
 
41
- # Install dependencies using uv sync
42
- # If uv.lock exists, use it; otherwise resolve on the fly
43
  RUN --mount=type=cache,target=/root/.cache/uv \
44
- if [ -f uv.lock ]; then \
45
- uv sync --frozen --no-install-project --no-editable; \
46
- else \
47
- uv sync --no-install-project --no-editable; \
48
- fi
49
 
50
  RUN --mount=type=cache,target=/root/.cache/uv \
51
- if [ -f uv.lock ]; then \
52
- uv sync --frozen --no-editable; \
53
- else \
54
- uv sync --no-editable; \
55
- fi
56
 
57
  # Final runtime stage
58
  FROM ${BASE_IMAGE}
@@ -67,15 +53,20 @@ COPY --from=builder /app/env /app/env
67
 
68
  # Set PATH to use the virtual environment
69
  ENV PATH="/app/.venv/bin:$PATH"
 
 
70
 
71
  # Set PYTHONPATH so imports work correctly
72
  ENV PYTHONPATH="/app/env:$PYTHONPATH"
73
 
 
 
 
74
  # Health check
75
  HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
76
- CMD curl -f http://localhost:8000/health || exit 1
77
 
78
  # Run the FastAPI server
79
- # The module path is constructed to work with the /app/env structure
80
  ENV ENABLE_WEB_INTERFACE=true
81
- CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000"]
 
20
  apt-get install -y --no-install-recommends git && \
21
  rm -rf /var/lib/apt/lists/*
22
 
 
 
 
 
23
  # Copy environment code (always at root of build context)
24
  COPY . /app/env
25
 
 
34
  mv /root/.local/bin/uvx /usr/local/bin/uvx; \
35
  fi
36
 
 
 
37
  RUN --mount=type=cache,target=/root/.cache/uv \
38
+ uv sync --no-install-project --no-editable
 
 
 
 
39
 
40
  RUN --mount=type=cache,target=/root/.cache/uv \
41
+ uv sync --no-editable
 
 
 
 
42
 
43
  # Final runtime stage
44
  FROM ${BASE_IMAGE}
 
53
 
54
  # Set PATH to use the virtual environment
55
  ENV PATH="/app/.venv/bin:$PATH"
56
+ ENV PYTHONDONTWRITEBYTECODE=1
57
+ ENV PYTHONUNBUFFERED=1
58
 
59
  # Set PYTHONPATH so imports work correctly
60
  ENV PYTHONPATH="/app/env:$PYTHONPATH"
61
 
62
+ # Document the runtime port for local operators/orchestrators
63
+ EXPOSE 8000
64
+
65
  # Health check
66
  HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
67
+ CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=2)"
68
 
69
  # Run the FastAPI server
70
+ # Use exec-form CMD for proper signal handling.
71
  ENV ENABLE_WEB_INTERFACE=true
72
+ CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "8000"]
pyproject.toml CHANGED
@@ -18,7 +18,7 @@ dependencies = [
18
  # install from github
19
  # "openenv-core[core] @ git+https://github.com/meta-pytorch/OpenEnv.git",
20
  "openenv-core[core]>=0.2.2",
21
- "yfinance>=0.2.0"
22
  # Environment-specific dependencies
23
  # Add all dependencies needed for your environment here
24
  # Examples:
 
18
  # install from github
19
  # "openenv-core[core] @ git+https://github.com/meta-pytorch/OpenEnv.git",
20
  "openenv-core[core]>=0.2.2",
21
+ "yfinance>=0.2.0",
22
  # Environment-specific dependencies
23
  # Add all dependencies needed for your environment here
24
  # Examples:
server/app.py CHANGED
@@ -38,7 +38,7 @@ except Exception as e: # pragma: no cover
38
  try:
39
  from ..models import FinenvAction, FinenvObservation
40
  from .finenv_environment import FinenvEnvironment
41
- except ModuleNotFoundError:
42
  from models import FinenvAction, FinenvObservation
43
  from server.finenv_environment import FinenvEnvironment
44
 
 
38
  try:
39
  from ..models import FinenvAction, FinenvObservation
40
  from .finenv_environment import FinenvEnvironment
41
+ except ImportError:
42
  from models import FinenvAction, FinenvObservation
43
  from server.finenv_environment import FinenvEnvironment
44
 
server/finenv_environment.py CHANGED
@@ -21,15 +21,14 @@ from uuid import uuid4
21
 
22
  from openenv.core.env_server.interfaces import Environment
23
  from openenv.core.env_server.types import State
24
-
25
  try:
26
  from ..models import FinenvAction, FinenvObservation, StockExchangeMarket
27
- from server.stock_price import get_stock_price
28
- from server.reward import reward_message
29
  except ImportError:
30
  from models import FinenvAction, FinenvObservation, StockExchangeMarket
31
- from .stock_price import get_stock_price
32
- from .reward import reward_message
33
 
34
 
35
  class FinenvEnvironment(Environment):
 
21
 
22
  from openenv.core.env_server.interfaces import Environment
23
  from openenv.core.env_server.types import State
 
24
  try:
25
  from ..models import FinenvAction, FinenvObservation, StockExchangeMarket
26
+ from .reward import reward_message
27
+ from .stock_price import get_stock_price
28
  except ImportError:
29
  from models import FinenvAction, FinenvObservation, StockExchangeMarket
30
+ from server.reward import reward_message
31
+ from server.stock_price import get_stock_price
32
 
33
 
34
  class FinenvEnvironment(Environment):
server/reward.py CHANGED
@@ -3,10 +3,6 @@ It developes a sentence based in the reward value.
3
  Positive rewards generate encouraging messages, negative rewards generate constructive feedback, and zero rewards generate neutral prompts to motivate improvement."""
4
 
5
 
6
- import random
7
-
8
- from sympy import Integer
9
-
10
  import random
11
 
12
  def reward_message(num:float) -> str:
 
3
  Positive rewards generate encouraging messages, negative rewards generate constructive feedback, and zero rewards generate neutral prompts to motivate improvement."""
4
 
5
 
 
 
 
 
6
  import random
7
 
8
  def reward_message(num:float) -> str: