Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit 5ce073d

Browse files
committed
Finish refactoring the Exporter class and improve hooks handling
1 parent 263cfc9 commit 5ce073d

7 files changed

Lines changed: 626 additions & 550 deletions

File tree

packages/jumpstarter/jumpstarter/common/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@
55
from datetime import timedelta
66
from functools import partial
77
from subprocess import Popen
8+
from typing import TYPE_CHECKING
89

910
from anyio.from_thread import BlockingPortal, start_blocking_portal
1011

1112
from jumpstarter.client import client_from_path
1213
from jumpstarter.config.env import JMP_DRIVERS_ALLOW, JUMPSTARTER_HOST
13-
from jumpstarter.driver import Driver
1414
from jumpstarter.exporter import Session
1515
from jumpstarter.utils.env import env
1616

17+
if TYPE_CHECKING:
18+
from jumpstarter.driver import Driver
19+
1720
__all__ = ["env"]
1821

1922

2023
@asynccontextmanager
21-
async def serve_async(root_device: Driver, portal: BlockingPortal, stack: ExitStack):
24+
async def serve_async(root_device: "Driver", portal: BlockingPortal, stack: ExitStack):
2225
with Session(root_device=root_device) as session:
2326
async with session.serve_unix_async() as path:
2427
# SAFETY: the root_device instance is constructed locally thus considered trusted
@@ -31,7 +34,7 @@ async def serve_async(root_device: Driver, portal: BlockingPortal, stack: ExitSt
3134

3235

3336
@contextmanager
34-
def serve(root_device: Driver):
37+
def serve(root_device: "Driver"):
3538
with start_blocking_portal() as portal:
3639
with ExitStack() as stack:
3740
with portal.wrap_async_context_manager(serve_async(root_device, portal, stack)) as client:

packages/jumpstarter/jumpstarter/config/exporter.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from contextlib import asynccontextmanager, contextmanager, suppress
44
from pathlib import Path
5-
from typing import Any, ClassVar, Literal, Optional, Self
5+
from typing import TYPE_CHECKING, Any, ClassVar, Literal, Optional, Self
66

77
import grpc
88
import yaml
@@ -15,7 +15,9 @@
1515
from jumpstarter.common.exceptions import ConfigurationError
1616
from jumpstarter.common.grpc import aio_secure_channel, ssl_channel_credentials
1717
from jumpstarter.common.importlib import import_class
18-
from jumpstarter.driver import Driver
18+
19+
if TYPE_CHECKING:
20+
from jumpstarter.driver import Driver
1921

2022

2123
class HookInstanceConfigV1Alpha1(BaseModel):
@@ -71,7 +73,7 @@ class ExporterConfigV1Alpha1DriverInstance(RootModel):
7173
| ExporterConfigV1Alpha1DriverInstanceProxy
7274
)
7375

74-
def instantiate(self) -> Driver:
76+
def instantiate(self) -> "Driver":
7577
match self.root:
7678
case ExporterConfigV1Alpha1DriverInstanceBase():
7779
driver_class = import_class(self.root.type, [], True)

packages/jumpstarter/jumpstarter/exporter/exporter.py

Lines changed: 99 additions & 187 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)