Skip to content
Open
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
14 changes: 12 additions & 2 deletions src/forge/actors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

from .collector import Collector
__all__ = ["Policy", "PolicyRouter"]

__all__ = ["Collector"]

def __getattr__(name):
if name == "Policy":
from .policy import Policy

return Policy
if name == "PolicyRouter":
from .policy import PolicyRouter

return PolicyRouter
raise AttributeError("fmodule {__name__} has no attribute {name}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise AttributeError("fmodule {__name__} has no attribute {name}")
raise AttributeError(f"module {__name__} has no attribute {name}")

46 changes: 41 additions & 5 deletions src/forge/controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from .actor import ForgeActor
from .interface import ServiceInterface, Session, SessionContext
from .proc_mesh import get_proc_mesh, spawn_actors
from .service import Service, ServiceConfig
from .spawn import spawn_service

__all__ = [
"Service",
Expand All @@ -20,3 +15,44 @@
"get_proc_mesh",
"ForgeActor",
]


def __getattr__(name):
if name == "Service":
from .service import Service

return Service
elif name == "ServiceConfig":
from .service import ServiceConfig

return ServiceConfig
elif name == "ServiceInterface":
from .interface import ServiceInterface

return ServiceInterface
elif name == "Session":
from .interface import Session

return Session
elif name == "SessionContext":
from .interface import SessionContext

return SessionContext
elif name == "spawn_service":
from .spawn import spawn_service

return spawn_service
elif name == "spawn_actors":
from .proc_mesh import spawn_actors

return spawn_actors
elif name == "get_proc_mesh":
from .proc_mesh import get_proc_mesh

return get_proc_mesh
elif name == "ForgeActor":
from .actor import ForgeActor

return ForgeActor
else:
raise AttributeError(f"module {__name__} has no attribute {name}")
15 changes: 13 additions & 2 deletions src/forge/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from .collate import collate_packed
from .utils import CROSS_ENTROPY_IGNORE_IDX

__all__ = ["collate_packed", "CROSS_ENTROPY_IGNORE_IDX"]


def __getattr__(name):
if name == "collate_packed":
from .collate import collate_packed

return collate_packed
elif name == "CROSS_ENTROPY_IGNORE_IDX":
from .utils import CROSS_ENTROPY_IGNORE_IDX

return CROSS_ENTROPY_IGNORE_IDX
else:
raise AttributeError(f"module {__name__} has no attribute {name}")
Loading