Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- envs/finrl_env/server/finrl_environment.py +8 -2
- server/finrl_environment.py +8 -2
- src/core/__init__.py +36 -6
- src/core/openenv/__init__.py +37 -6
- src/core/openenv/core/__init__.py +36 -6
- src/openenv/__init__.py +37 -6
- src/openenv/core/__init__.py +36 -6
envs/finrl_env/server/finrl_environment.py
CHANGED
|
@@ -13,8 +13,14 @@ Wraps FinRL's StockTradingEnv to conform to the OpenEnv interface.
|
|
| 13 |
from uuid import uuid4
|
| 14 |
|
| 15 |
import numpy as np
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
from ..models import FinRLAction, FinRLObservation
|
| 20 |
|
|
|
|
| 13 |
from uuid import uuid4
|
| 14 |
|
| 15 |
import numpy as np
|
| 16 |
+
|
| 17 |
+
try:
|
| 18 |
+
# Prefer legacy /app/src/core import path in staged HF deployments.
|
| 19 |
+
from core.env_server.interfaces import Environment
|
| 20 |
+
from core.env_server.types import State
|
| 21 |
+
except ImportError:
|
| 22 |
+
from openenv.core.env_server.interfaces import Environment
|
| 23 |
+
from openenv.core.env_server.types import State
|
| 24 |
|
| 25 |
from ..models import FinRLAction, FinRLObservation
|
| 26 |
|
server/finrl_environment.py
CHANGED
|
@@ -13,8 +13,14 @@ Wraps FinRL's StockTradingEnv to conform to the OpenEnv interface.
|
|
| 13 |
from uuid import uuid4
|
| 14 |
|
| 15 |
import numpy as np
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
from ..models import FinRLAction, FinRLObservation
|
| 20 |
|
|
|
|
| 13 |
from uuid import uuid4
|
| 14 |
|
| 15 |
import numpy as np
|
| 16 |
+
|
| 17 |
+
try:
|
| 18 |
+
# Prefer legacy /app/src/core import path in staged HF deployments.
|
| 19 |
+
from core.env_server.interfaces import Environment
|
| 20 |
+
from core.env_server.types import State
|
| 21 |
+
except ImportError:
|
| 22 |
+
from openenv.core.env_server.interfaces import Environment
|
| 23 |
+
from openenv.core.env_server.types import State
|
| 24 |
|
| 25 |
from ..models import FinRLAction, FinRLObservation
|
| 26 |
|
src/core/__init__.py
CHANGED
|
@@ -6,13 +6,12 @@
|
|
| 6 |
|
| 7 |
"""Core components for agentic environments."""
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
from . import env_server
|
| 12 |
-
from .
|
| 13 |
-
from .sync_client import SyncEnvClient
|
| 14 |
-
from .generic_client import GenericEnvClient, GenericAction
|
| 15 |
-
from .mcp_client import MCPClientBase, MCPToolClient
|
| 16 |
|
| 17 |
__all__ = [
|
| 18 |
"EnvClient",
|
|
@@ -22,3 +21,34 @@ __all__ = [
|
|
| 22 |
"MCPClientBase",
|
| 23 |
"MCPToolClient",
|
| 24 |
] + env_server.__all__ # type: ignore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
"""Core components for agentic environments."""
|
| 8 |
|
| 9 |
+
from __future__ import annotations
|
| 10 |
+
|
| 11 |
+
from importlib import import_module
|
| 12 |
+
|
| 13 |
from . import env_server
|
| 14 |
+
from .env_server import * # noqa: F403
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
__all__ = [
|
| 17 |
"EnvClient",
|
|
|
|
| 21 |
"MCPClientBase",
|
| 22 |
"MCPToolClient",
|
| 23 |
] + env_server.__all__ # type: ignore
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
_LAZY_ATTRS = {
|
| 27 |
+
"EnvClient": (".env_client", "EnvClient"),
|
| 28 |
+
"SyncEnvClient": (".sync_client", "SyncEnvClient"),
|
| 29 |
+
"GenericEnvClient": (".generic_client", "GenericEnvClient"),
|
| 30 |
+
"GenericAction": (".generic_client", "GenericAction"),
|
| 31 |
+
"MCPClientBase": (".mcp_client", "MCPClientBase"),
|
| 32 |
+
"MCPToolClient": (".mcp_client", "MCPToolClient"),
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def __getattr__(name: str):
|
| 37 |
+
if name in _LAZY_ATTRS:
|
| 38 |
+
module_path, attr_name = _LAZY_ATTRS[name]
|
| 39 |
+
module = import_module(module_path, __name__)
|
| 40 |
+
value = getattr(module, attr_name)
|
| 41 |
+
globals()[name] = value
|
| 42 |
+
return value
|
| 43 |
+
|
| 44 |
+
try:
|
| 45 |
+
value = getattr(env_server, name)
|
| 46 |
+
except AttributeError as exc:
|
| 47 |
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from exc
|
| 48 |
+
|
| 49 |
+
globals()[name] = value
|
| 50 |
+
return value
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def __dir__() -> list[str]:
|
| 54 |
+
return sorted(set(globals().keys()) | set(__all__))
|
src/core/openenv/__init__.py
CHANGED
|
@@ -1,11 +1,8 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Unified OpenEnv package bundling the CLI and core runtime.
|
| 3 |
-
"""
|
| 4 |
|
| 5 |
-
from
|
| 6 |
|
| 7 |
-
from
|
| 8 |
-
from .core import GenericEnvClient, GenericAction, SyncEnvClient
|
| 9 |
|
| 10 |
__all__ = [
|
| 11 |
"core",
|
|
@@ -21,3 +18,37 @@ try:
|
|
| 21 |
__version__ = metadata.version("openenv") # type: ignore[arg-type]
|
| 22 |
except metadata.PackageNotFoundError: # pragma: no cover - local dev
|
| 23 |
__version__ = "0.0.0"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Unified OpenEnv package bundling the CLI and core runtime."""
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
from __future__ import annotations
|
| 4 |
|
| 5 |
+
from importlib import import_module, metadata
|
|
|
|
| 6 |
|
| 7 |
__all__ = [
|
| 8 |
"core",
|
|
|
|
| 18 |
__version__ = metadata.version("openenv") # type: ignore[arg-type]
|
| 19 |
except metadata.PackageNotFoundError: # pragma: no cover - local dev
|
| 20 |
__version__ = "0.0.0"
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
_LAZY_MODULES = {
|
| 24 |
+
"core": ".core",
|
| 25 |
+
"cli": ".cli",
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
_LAZY_ATTRS = {
|
| 29 |
+
"AutoEnv": (".auto", "AutoEnv"),
|
| 30 |
+
"AutoAction": (".auto", "AutoAction"),
|
| 31 |
+
"GenericEnvClient": (".core", "GenericEnvClient"),
|
| 32 |
+
"GenericAction": (".core", "GenericAction"),
|
| 33 |
+
"SyncEnvClient": (".core", "SyncEnvClient"),
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def __getattr__(name: str):
|
| 38 |
+
if name in _LAZY_MODULES:
|
| 39 |
+
module = import_module(_LAZY_MODULES[name], __name__)
|
| 40 |
+
globals()[name] = module
|
| 41 |
+
return module
|
| 42 |
+
|
| 43 |
+
if name in _LAZY_ATTRS:
|
| 44 |
+
module_path, attr_name = _LAZY_ATTRS[name]
|
| 45 |
+
module = import_module(module_path, __name__)
|
| 46 |
+
value = getattr(module, attr_name)
|
| 47 |
+
globals()[name] = value
|
| 48 |
+
return value
|
| 49 |
+
|
| 50 |
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def __dir__() -> list[str]:
|
| 54 |
+
return sorted(set(globals().keys()) | set(__all__))
|
src/core/openenv/core/__init__.py
CHANGED
|
@@ -6,13 +6,12 @@
|
|
| 6 |
|
| 7 |
"""Core components for agentic environments."""
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
from . import env_server
|
| 12 |
-
from .
|
| 13 |
-
from .sync_client import SyncEnvClient
|
| 14 |
-
from .generic_client import GenericEnvClient, GenericAction
|
| 15 |
-
from .mcp_client import MCPClientBase, MCPToolClient
|
| 16 |
|
| 17 |
__all__ = [
|
| 18 |
"EnvClient",
|
|
@@ -22,3 +21,34 @@ __all__ = [
|
|
| 22 |
"MCPClientBase",
|
| 23 |
"MCPToolClient",
|
| 24 |
] + env_server.__all__ # type: ignore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
"""Core components for agentic environments."""
|
| 8 |
|
| 9 |
+
from __future__ import annotations
|
| 10 |
+
|
| 11 |
+
from importlib import import_module
|
| 12 |
+
|
| 13 |
from . import env_server
|
| 14 |
+
from .env_server import * # noqa: F403
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
__all__ = [
|
| 17 |
"EnvClient",
|
|
|
|
| 21 |
"MCPClientBase",
|
| 22 |
"MCPToolClient",
|
| 23 |
] + env_server.__all__ # type: ignore
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
_LAZY_ATTRS = {
|
| 27 |
+
"EnvClient": (".env_client", "EnvClient"),
|
| 28 |
+
"SyncEnvClient": (".sync_client", "SyncEnvClient"),
|
| 29 |
+
"GenericEnvClient": (".generic_client", "GenericEnvClient"),
|
| 30 |
+
"GenericAction": (".generic_client", "GenericAction"),
|
| 31 |
+
"MCPClientBase": (".mcp_client", "MCPClientBase"),
|
| 32 |
+
"MCPToolClient": (".mcp_client", "MCPToolClient"),
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def __getattr__(name: str):
|
| 37 |
+
if name in _LAZY_ATTRS:
|
| 38 |
+
module_path, attr_name = _LAZY_ATTRS[name]
|
| 39 |
+
module = import_module(module_path, __name__)
|
| 40 |
+
value = getattr(module, attr_name)
|
| 41 |
+
globals()[name] = value
|
| 42 |
+
return value
|
| 43 |
+
|
| 44 |
+
try:
|
| 45 |
+
value = getattr(env_server, name)
|
| 46 |
+
except AttributeError as exc:
|
| 47 |
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from exc
|
| 48 |
+
|
| 49 |
+
globals()[name] = value
|
| 50 |
+
return value
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def __dir__() -> list[str]:
|
| 54 |
+
return sorted(set(globals().keys()) | set(__all__))
|
src/openenv/__init__.py
CHANGED
|
@@ -1,11 +1,8 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Unified OpenEnv package bundling the CLI and core runtime.
|
| 3 |
-
"""
|
| 4 |
|
| 5 |
-
from
|
| 6 |
|
| 7 |
-
from
|
| 8 |
-
from .core import GenericEnvClient, GenericAction, SyncEnvClient
|
| 9 |
|
| 10 |
__all__ = [
|
| 11 |
"core",
|
|
@@ -21,3 +18,37 @@ try:
|
|
| 21 |
__version__ = metadata.version("openenv") # type: ignore[arg-type]
|
| 22 |
except metadata.PackageNotFoundError: # pragma: no cover - local dev
|
| 23 |
__version__ = "0.0.0"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Unified OpenEnv package bundling the CLI and core runtime."""
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
from __future__ import annotations
|
| 4 |
|
| 5 |
+
from importlib import import_module, metadata
|
|
|
|
| 6 |
|
| 7 |
__all__ = [
|
| 8 |
"core",
|
|
|
|
| 18 |
__version__ = metadata.version("openenv") # type: ignore[arg-type]
|
| 19 |
except metadata.PackageNotFoundError: # pragma: no cover - local dev
|
| 20 |
__version__ = "0.0.0"
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
_LAZY_MODULES = {
|
| 24 |
+
"core": ".core",
|
| 25 |
+
"cli": ".cli",
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
_LAZY_ATTRS = {
|
| 29 |
+
"AutoEnv": (".auto", "AutoEnv"),
|
| 30 |
+
"AutoAction": (".auto", "AutoAction"),
|
| 31 |
+
"GenericEnvClient": (".core", "GenericEnvClient"),
|
| 32 |
+
"GenericAction": (".core", "GenericAction"),
|
| 33 |
+
"SyncEnvClient": (".core", "SyncEnvClient"),
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def __getattr__(name: str):
|
| 38 |
+
if name in _LAZY_MODULES:
|
| 39 |
+
module = import_module(_LAZY_MODULES[name], __name__)
|
| 40 |
+
globals()[name] = module
|
| 41 |
+
return module
|
| 42 |
+
|
| 43 |
+
if name in _LAZY_ATTRS:
|
| 44 |
+
module_path, attr_name = _LAZY_ATTRS[name]
|
| 45 |
+
module = import_module(module_path, __name__)
|
| 46 |
+
value = getattr(module, attr_name)
|
| 47 |
+
globals()[name] = value
|
| 48 |
+
return value
|
| 49 |
+
|
| 50 |
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def __dir__() -> list[str]:
|
| 54 |
+
return sorted(set(globals().keys()) | set(__all__))
|
src/openenv/core/__init__.py
CHANGED
|
@@ -6,13 +6,12 @@
|
|
| 6 |
|
| 7 |
"""Core components for agentic environments."""
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
from . import env_server
|
| 12 |
-
from .
|
| 13 |
-
from .sync_client import SyncEnvClient
|
| 14 |
-
from .generic_client import GenericEnvClient, GenericAction
|
| 15 |
-
from .mcp_client import MCPClientBase, MCPToolClient
|
| 16 |
|
| 17 |
__all__ = [
|
| 18 |
"EnvClient",
|
|
@@ -22,3 +21,34 @@ __all__ = [
|
|
| 22 |
"MCPClientBase",
|
| 23 |
"MCPToolClient",
|
| 24 |
] + env_server.__all__ # type: ignore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
"""Core components for agentic environments."""
|
| 8 |
|
| 9 |
+
from __future__ import annotations
|
| 10 |
+
|
| 11 |
+
from importlib import import_module
|
| 12 |
+
|
| 13 |
from . import env_server
|
| 14 |
+
from .env_server import * # noqa: F403
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
__all__ = [
|
| 17 |
"EnvClient",
|
|
|
|
| 21 |
"MCPClientBase",
|
| 22 |
"MCPToolClient",
|
| 23 |
] + env_server.__all__ # type: ignore
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
_LAZY_ATTRS = {
|
| 27 |
+
"EnvClient": (".env_client", "EnvClient"),
|
| 28 |
+
"SyncEnvClient": (".sync_client", "SyncEnvClient"),
|
| 29 |
+
"GenericEnvClient": (".generic_client", "GenericEnvClient"),
|
| 30 |
+
"GenericAction": (".generic_client", "GenericAction"),
|
| 31 |
+
"MCPClientBase": (".mcp_client", "MCPClientBase"),
|
| 32 |
+
"MCPToolClient": (".mcp_client", "MCPToolClient"),
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def __getattr__(name: str):
|
| 37 |
+
if name in _LAZY_ATTRS:
|
| 38 |
+
module_path, attr_name = _LAZY_ATTRS[name]
|
| 39 |
+
module = import_module(module_path, __name__)
|
| 40 |
+
value = getattr(module, attr_name)
|
| 41 |
+
globals()[name] = value
|
| 42 |
+
return value
|
| 43 |
+
|
| 44 |
+
try:
|
| 45 |
+
value = getattr(env_server, name)
|
| 46 |
+
except AttributeError as exc:
|
| 47 |
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from exc
|
| 48 |
+
|
| 49 |
+
globals()[name] = value
|
| 50 |
+
return value
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def __dir__() -> list[str]:
|
| 54 |
+
return sorted(set(globals().keys()) | set(__all__))
|