Skip to main content

myexp

myexp is the maintained Python protocol package for repository experiment scripts. Version 0.2.0 keeps the runtime contract from 0.1.0 while making the public API smaller and better diagnosed.

Runtime Model

One script supports both local debug and distributed runtime execution:

  • local debug mode uses defaults embedded in the script;
  • runtime mode uses the JSON object passed as the first command-line argument;
  • runtime JSON is authoritative and never merged under local defaults.

Use myexp.params(local_defaults) to load parameters. If runtime JSON is present it is returned. If no runtime JSON is present, a deep copy of local_defaults is returned. Invalid JSON and non-object JSON raise ParameterError with phase, source, path, and recovery guidance.

Preferred API

New scripts should import only myexp and prefer these names:

  • myexp.params(local_defaults) and myexp.in_runtime()
  • myexp.emit(result)
  • myexp.run_experiment(func, local_defaults=...)
  • myexp.ExperimentTemplate for YAML-backed lifecycle scripts
  • myexp.config_name(__file__)
  • myexp.load_config(...), myexp.nest_params(...), myexp.unpack_params(...)
  • myexp.filter_kwargs(func, args)

Compatibility names remain available for existing scripts:

  • ExpTemplate, getParams, printResult, isExpEnv
  • getYamlConfName, parseFuncParams, unpackAggrParam
  • convParam2Setting, loadSettingFromYaml, removeNoneSetting

Minimal Script

import myexp

LOCAL_DEFAULTS = {"pid": 0, "metric": 1}


def main(param):
    return {"metric": int(param["metric"]) + 1, "params": param}


if __name__ == "__main__":
    myexp.run_experiment(main, local_defaults=LOCAL_DEFAULTS)

Lifecycle Script

Use ExperimentTemplate when the script needs bgConfig.yaml, a task config file, option/reference parsing, pid document selection, execution gating, or parameter normalization.

import myexp


class Experiment(myexp.ExperimentTemplate):
    def normalize_params(self, param):
        param["metric"] = int(param["metric"]) + 1
        return param

    def execute(self, config):
        return {"metric": config["metric"], "params": config}


if __name__ == "__main__":
    Experiment(
        workSpaceDir=".",
        taskConfigName=myexp.config_name(__file__),
        local_defaults={"pid": 0, "metric": 1},
    ).run()

Config Behavior

Config loading is deterministic:

  1. load the selected background YAML document;
  2. merge the selected task YAML document;
  3. merge parameter overrides after converting a__b to a.b;
  4. parse option blocks using $ selectors with exact match, one regex match, or default;
  5. resolve ?path.to.key references;
  6. raise ConfigError for missing config files, missing reference paths, ambiguous options, cycles, unsupported YAML document shapes, or invalid pid/document indices.

Results are sidecar-first. When RESEARCH_LAB_RESULT_JSON is set, myexp.emit() writes JSON there. Otherwise it emits the legacy stdout markers ==>**ResultJson**<== and ==>**End**<==.

Release files for myexp 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for myexp 0.2.0
File Size Uploaded
myexp-0.2.0.tar.gz 14.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for myexp 0.2.0
File Interpreter ABI Platform
myexp-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.8 kB

Release files / myexp-0.2.0.tar.gz

Download URL myexp-0.2.0.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c979e83d9904b3ff55ed37740fb64f3c6eab4091fafe9f33cd0303067cff2cfe
BLAKE2b-256 checksum
How to use checksums
ed63576e9ecedacc1a95f1ffdc4f582a89fc0e48f918ff30a6127371204722e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / myexp-0.2.0-py3-none-any.whl

Download URL myexp-0.2.0-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f1da0ba038e4bb1ad16ffdd6f4177e27d2a249c1706880af3e6ee70d2e3641a
BLAKE2b-256 checksum
How to use checksums
d4724c57bc3f7bfa436e5e102c5444c0f5048abea1a6cfccadae924ebce84088
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page