Skip to content

Commit

Permalink
Pass path mapping data to backend in daemon mode
Browse files Browse the repository at this point in the history
  • Loading branch information
agerveshi committed Oct 9, 2023
1 parent 39d557c commit 84dce0e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/openjd/adaptor_runtime/_background/frontend_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ def __init__(
signal.signal(signal.SIGINT, self._sigint_handler)
signal.signal(signal.SIGTERM, self._sigint_handler)

def init(self, adaptor_module: ModuleType, init_data: dict = {}) -> None:
def init(self, adaptor_module: ModuleType, init_data: dict = {}, path_mapping_data: dict = {}) -> None:
"""
Creates the backend process then sends a heartbeat request to verify that it has started
successfully.
Args:
adaptor_module (ModuleType): The module of the adaptor running the runtime.
init_data (dict): Data to pass to the adaptor during initialization.
path_mapping_data (dict): Path mapping rules to make available to the adaptor while it's running.
"""
if adaptor_module.__package__ is None:
raise Exception(f"Adaptor module is not a package: {adaptor_module}")
Expand All @@ -85,6 +87,8 @@ def init(self, adaptor_module: ModuleType, init_data: dict = {}) -> None:
self._connection_file_path,
"--init-data",
json.dumps(init_data),
"--path-mapping-rules",
json.dumps(path_mapping_data),
]
try:
process = subprocess.Popen(
Expand Down
4 changes: 2 additions & 2 deletions src/openjd/adaptor_runtime/_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def start(self) -> None:
f"Adaptor module is not loaded: {self.adaptor_class.__module__}"
)

frontend.init(adaptor_module, init_data)
frontend.init(adaptor_module, init_data, path_mapping_data)
frontend.start()
elif subcommand == "run":
frontend.run(run_data)
Expand Down Expand Up @@ -266,7 +266,7 @@ def _build_argparser(self) -> ArgumentParser:
)

# "Hidden" command that actually runs the adaptor runtime in background mode
bg_subparser.add_parser("_serve", parents=[init_data, connection_file])
bg_subparser.add_parser("_serve", parents=[init_data, path_mapping_rules, connection_file])

bg_subparser.add_parser("start", parents=[init_data, path_mapping_rules, connection_file])
bg_subparser.add_parser("run", parents=[run_data, connection_file])
Expand Down

0 comments on commit 84dce0e

Please sign in to comment.