Operator registry and async-friendly execution layer for Jarvis
Project description
Jarvis-Operas
Jarvis-Operas is a standalone operator layer for registering, discovering, loading, and calling Python callables.
- Scope: operators only (likelihood, chi2, prior mapping, data transforms, etc.)
- No dependency on Jarvis-HEP internals
- Native async entrypoint for Jarvis-HEP style execution (
await registry.acall(...)) - Stable
"<namespace>:<name>"naming for references from Jarvis-HEP/Jarvis-PLOT YAML
Install
pip install .
Or for development (includes pytest and installs terminal command):
pip install -e ".[dev]"
Terminal command (jopera)
After install, you can use:
jopera list --namespace core
jopera info core:chi2_cov --json
jopera call core:add --kwargs '{"a": 1, "b": 2}'
jopera acall core:chi2_cov --arg residual=[1.0,-0.5] --arg cov=[[2.0,0.1],[0.1,1.0]]
jopera list --namespace core --log-mode info
jopera call core:add --kwargs '{"a": 1, "b": 2}' --log-mode debug
Load user operators directly in CLI:
jopera call user:my_op --user-ops /absolute/path/to/my_ops.py --arg x=10
Core API
from jarvis_operas import get_global_registry
registry = get_global_registry()
registry.call("core:add", a=1, b=2)
registry.call("core:identity", x={"k": 1})
Supported namespace convention:
core:<name>: built-in/offical operatorsuser:<name>: user-defined operators
Async call (Jarvis-HEP Factory/Module friendly)
result = await registry.acall(
"core:chi2_cov",
residual=[1.0, -0.5],
cov=[[2.0, 0.1], [0.1, 1.0]],
observables={"obs": 1.0},
sample_info={"id": 42},
cfg={"mode": "demo"},
)
Behavior:
- Async operator: awaited directly
- Sync operator: offloaded via
asyncio.to_threadby default (or custom executor)
Logger injection
registry methods accept optional logger and operators can optionally define logger argument.
- If no logger is provided, Jarvis-Operas uses
loguru.loggerbound withmodule="Jarvis-Operas" - If logger is provided, Jarvis-Operas reuses it (no duplicate handler creation)
- Console format follows Jarvis-HEP style (
module -> time - [level] >>> message) - Default mode is
warning(only warning/error/critical are shown) - Optional modes:
info,debug
Utility:
from jarvis_operas import get_logger, set_log_mode
set_log_mode("info") # or "debug", default is "warning"
logger = get_logger()
Load user operators from file
from jarvis_operas import OperatorRegistry, load_user_ops
registry = OperatorRegistry()
loaded = load_user_ops("./my_ops.py", registry)
print(loaded)
my_ops.py can export operators with either style:
- Decorator (recommended)
from jarvis_operas import oper
@oper("my_chi2", namespace="user")
def my_chi2(residual, cov, logger=None):
...
- Explicit whitelist
def my_op(x):
return x
__JARVIS_OPERAS__ = {
"my_op": my_op,
}
Discover plugins by entry points
from jarvis_operas import discover_entrypoints, get_global_registry
registry = get_global_registry()
discover_entrypoints(registry)
Supported groups:
jarvis_operas.corejarvis_operas.user
Built-in operators
core:identity(x)core:add(a, b)core:chi2_cov(residual, cov)
Query registry for external UIs (JHEP/JPlot)
registry.list()
registry.list(namespace="core")
registry.info("core:chi2_cov")
registry.info(...) returns metadata, signature, docstring summary, module/qualname, and async flag.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jarvis_operas-0.1.0.tar.gz.
File metadata
- Download URL: jarvis_operas-0.1.0.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5216b403956c3deffc31e036133c2f26dd4ad4d45baabbd106e55a4d30332c41
|
|
| MD5 |
20d55050a1aab6a8ddd43c4c5cce7835
|
|
| BLAKE2b-256 |
87c0beb189206e2747a7bdfb40a40d94a03e907f1465d271eed69c43f8f564d6
|
File details
Details for the file jarvis_operas-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jarvis_operas-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60e3cdbef64f083e2dfa32fdead1f37ee1cbddd62e2a1d880575736db11ca864
|
|
| MD5 |
f5de40cbbb0a4d61ea9072894147e898
|
|
| BLAKE2b-256 |
27ab86e9b47379cd1ab1ad16238818cfcdd30bf9e4c32c04cf3069ea4d5fe968
|