-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9425f2
commit 3653a44
Showing
7 changed files
with
130 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.egg-info | ||
__jac_gen__ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import types | ||
from typing import Optional, Union | ||
|
||
from jaclang.plugin.default import hookimpl | ||
from jaclang.runtimelib.importer import ImportPathSpec, JacImporter, PythonImporter | ||
from jaclang.runtimelib.machine import JacMachine, JacProgram | ||
from jaclang.settings import settings | ||
from managers.proxy_manager import ModuleProxy | ||
import pluggy | ||
|
||
hookimpl = pluggy.HookimplMarker("jac") | ||
|
||
|
||
class SpliceOrcPlugin: | ||
@staticmethod | ||
@hookimpl | ||
def jac_import( | ||
target: str, | ||
base_path: str, | ||
absorb: bool, | ||
cachable: bool, | ||
mdl_alias: Optional[str], | ||
override_name: Optional[str], | ||
lng: Optional[str], | ||
items: Optional[dict[str, Union[str, Optional[str]]]], | ||
reload_module: Optional[bool], | ||
) -> tuple[types.ModuleType, ...]: | ||
"""Core Import Process with Kubernetes Pod Integration.""" | ||
print("Importing %s" % target) | ||
# Check if the target module is configured for remote execution | ||
if ( | ||
target in settings.module_config | ||
and settings.module_config[target]["load_type"] == "remote" | ||
): | ||
# Handle remote import using ProxyManager | ||
print(f"Loading module '{target}' remotely via Kubernetes.") | ||
|
||
# Initialize the ProxyManager for Kubernetes pod management | ||
proxy = ModuleProxy(settings.pod_manager_url) | ||
|
||
# This will handle pod creation, module loading, and execution | ||
remote_module_proxy = proxy.get_module_proxy( | ||
module_name=target, module_config=settings.module_config[target] | ||
) | ||
|
||
# Return the proxy for remote execution of methods | ||
return (remote_module_proxy,) | ||
|
||
# Default import process if not a remote module | ||
spec = ImportPathSpec( | ||
target, | ||
base_path, | ||
absorb, | ||
cachable, | ||
mdl_alias, | ||
override_name, | ||
lng, | ||
items, | ||
) | ||
|
||
jac_machine = JacMachine.get(base_path) | ||
if not jac_machine.jac_program: | ||
jac_machine.attach_program(JacProgram(mod_bundle=None, bytecode=None)) | ||
|
||
if lng == "py": | ||
# Import using PythonImporter if it's a Python module | ||
import_result = PythonImporter(JacMachine.get()).run_import(spec) | ||
else: | ||
# Otherwise, import using JacImporter | ||
import_result = JacImporter(JacMachine.get()).run_import( | ||
spec, reload_module | ||
) | ||
|
||
return ( | ||
(import_result.ret_mod,) | ||
if absorb or not items | ||
else tuple(import_result.ret_items) | ||
) | ||
|
||
|
||
plugin = SpliceOrcPlugin() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name="jac-splice-orc", | ||
version="0.1.0", | ||
description="JAC Splice-Orchestrator: Kubernetes-based dynamic remote module management for JacLang", | ||
author="Jason Mars", | ||
author_email="jason@jaseci.org", | ||
packages=find_packages(), | ||
install_requires=[ | ||
"fastapi", | ||
"uvicorn", | ||
"grpcio", | ||
"grpcio-tools", | ||
"kubernetes", | ||
"pydantic", | ||
], | ||
entry_points={ | ||
"jaclang.plugins": [ | ||
"splice_orc = plugin.splice_plugin", | ||
], | ||
}, | ||
python_requires=">=3.11", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import:py numpy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters