ofplang 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ofplang-0.1.0/.github/workflows/ci.yml +45 -0
- ofplang-0.1.0/.github/workflows/publish.yml +94 -0
- ofplang-0.1.0/.gitignore +14 -0
- ofplang-0.1.0/LICENSE +21 -0
- ofplang-0.1.0/PKG-INFO +88 -0
- ofplang-0.1.0/README.md +55 -0
- ofplang-0.1.0/ofplang/ofp/__init__.py +1 -0
- ofplang-0.1.0/ofplang/ofp/__main__.py +9 -0
- ofplang-0.1.0/ofplang/ofp/cli.py +92 -0
- ofplang-0.1.0/ofplang/ofp/py.typed +0 -0
- ofplang-0.1.0/ofplang.egg-info/PKG-INFO +88 -0
- ofplang-0.1.0/ofplang.egg-info/SOURCES.txt +19 -0
- ofplang-0.1.0/ofplang.egg-info/dependency_links.txt +1 -0
- ofplang-0.1.0/ofplang.egg-info/entry_points.txt +2 -0
- ofplang-0.1.0/ofplang.egg-info/requires.txt +11 -0
- ofplang-0.1.0/ofplang.egg-info/scm_file_list.json +15 -0
- ofplang-0.1.0/ofplang.egg-info/scm_version.json +8 -0
- ofplang-0.1.0/ofplang.egg-info/top_level.txt +1 -0
- ofplang-0.1.0/pyproject.toml +87 -0
- ofplang-0.1.0/setup.cfg +4 -0
- ofplang-0.1.0/tests/test_cli.py +47 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python-version }}
|
|
21
|
+
cache: pip
|
|
22
|
+
- run: pip install -e ".[test]"
|
|
23
|
+
- run: pytest
|
|
24
|
+
|
|
25
|
+
lint:
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
- uses: actions/setup-python@v5
|
|
30
|
+
with:
|
|
31
|
+
python-version: "3.12"
|
|
32
|
+
cache: pip
|
|
33
|
+
- run: pip install -e ".[dev]"
|
|
34
|
+
- run: ruff check ofplang tests
|
|
35
|
+
|
|
36
|
+
typecheck:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
- uses: actions/setup-python@v5
|
|
41
|
+
with:
|
|
42
|
+
python-version: "3.12"
|
|
43
|
+
cache: pip
|
|
44
|
+
- run: pip install -e ".[dev]"
|
|
45
|
+
- run: mypy
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
# Tag-driven release via PyPI Trusted Publishing (OIDC) — no API tokens.
|
|
4
|
+
#
|
|
5
|
+
# Version comes from the pushed git tag via setuptools-scm (`v0.1.0` -> 0.1.0).
|
|
6
|
+
# Routing:
|
|
7
|
+
# - a pre-release tag containing `rc` (e.g. v0.1.0rc1) -> TestPyPI (rehearsal)
|
|
8
|
+
# - any other `v*` tag (e.g. v0.1.0) -> PyPI (production)
|
|
9
|
+
# - manual workflow_dispatch -> choose the target explicitly (run it from a
|
|
10
|
+
# tagged commit, else setuptools-scm yields a dev+local version PyPI rejects)
|
|
11
|
+
#
|
|
12
|
+
# PyPI-side setup (done once, by the project owner): register a Trusted Publisher
|
|
13
|
+
# for owner=ofplang, repo=ofp, workflow=publish.yml, environment=pypi
|
|
14
|
+
# (and environment=testpypi on TestPyPI). First release: register as "pending".
|
|
15
|
+
# The published distribution name is `ofplang`.
|
|
16
|
+
|
|
17
|
+
on:
|
|
18
|
+
push:
|
|
19
|
+
tags: ["v*"]
|
|
20
|
+
workflow_dispatch:
|
|
21
|
+
inputs:
|
|
22
|
+
target:
|
|
23
|
+
description: "Publish target"
|
|
24
|
+
type: choice
|
|
25
|
+
options: [testpypi, pypi]
|
|
26
|
+
default: testpypi
|
|
27
|
+
|
|
28
|
+
jobs:
|
|
29
|
+
build:
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
with:
|
|
34
|
+
# setuptools-scm derives the version from tags + history.
|
|
35
|
+
fetch-depth: 0
|
|
36
|
+
- uses: actions/setup-python@v5
|
|
37
|
+
with:
|
|
38
|
+
python-version: "3.12"
|
|
39
|
+
- run: python -m pip install --upgrade build twine
|
|
40
|
+
- run: python -m build
|
|
41
|
+
- run: twine check dist/*
|
|
42
|
+
# Guard against ambiguous tags: the built version (from setuptools-scm) must
|
|
43
|
+
# equal the pushed tag — e.g. tag v0.1.0 must build 0.1.0. Catches a commit
|
|
44
|
+
# carrying two tags (an rc and a release) where git describe can resolve to
|
|
45
|
+
# the wrong one and publish the wrong artifact.
|
|
46
|
+
- name: Verify built version matches tag
|
|
47
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
48
|
+
shell: bash
|
|
49
|
+
run: |
|
|
50
|
+
tag="${GITHUB_REF_NAME#v}"
|
|
51
|
+
built="$(ls dist/*.tar.gz | sed -E 's#.*/[^/]*-([0-9][^-]*)\.tar\.gz#\1#')"
|
|
52
|
+
echo "tag=$tag built=$built"
|
|
53
|
+
if [ "$tag" != "$built" ]; then
|
|
54
|
+
echo "::error::built version $built != tag $tag (ambiguous or misplaced tag?)"
|
|
55
|
+
exit 1
|
|
56
|
+
fi
|
|
57
|
+
- uses: actions/upload-artifact@v4
|
|
58
|
+
with:
|
|
59
|
+
name: dist
|
|
60
|
+
path: dist/
|
|
61
|
+
|
|
62
|
+
publish-testpypi:
|
|
63
|
+
needs: build
|
|
64
|
+
if: >-
|
|
65
|
+
github.event_name == 'workflow_dispatch' && inputs.target == 'testpypi'
|
|
66
|
+
|| (github.event_name == 'push' && contains(github.ref_name, 'rc'))
|
|
67
|
+
runs-on: ubuntu-latest
|
|
68
|
+
environment: testpypi
|
|
69
|
+
permissions:
|
|
70
|
+
id-token: write
|
|
71
|
+
steps:
|
|
72
|
+
- uses: actions/download-artifact@v4
|
|
73
|
+
with:
|
|
74
|
+
name: dist
|
|
75
|
+
path: dist/
|
|
76
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
77
|
+
with:
|
|
78
|
+
repository-url: https://test.pypi.org/legacy/
|
|
79
|
+
|
|
80
|
+
publish-pypi:
|
|
81
|
+
needs: build
|
|
82
|
+
if: >-
|
|
83
|
+
github.event_name == 'workflow_dispatch' && inputs.target == 'pypi'
|
|
84
|
+
|| (github.event_name == 'push' && !contains(github.ref_name, 'rc'))
|
|
85
|
+
runs-on: ubuntu-latest
|
|
86
|
+
environment: pypi
|
|
87
|
+
permissions:
|
|
88
|
+
id-token: write
|
|
89
|
+
steps:
|
|
90
|
+
- uses: actions/download-artifact@v4
|
|
91
|
+
with:
|
|
92
|
+
name: dist
|
|
93
|
+
path: dist/
|
|
94
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
ofplang-0.1.0/.gitignore
ADDED
ofplang-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kazunari Kaizu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
ofplang-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ofplang
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Umbrella `ofp` command-line interface for the Object-flow Programming Language toolchain.
|
|
5
|
+
Author-email: Kazunari Kaizu <kwaizu@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ofplang/ofp
|
|
8
|
+
Project-URL: Repository, https://github.com/ofplang/ofp
|
|
9
|
+
Keywords: ofplang,dataflow,workflow,cli
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: ofplang-validate>=0.1.0
|
|
24
|
+
Requires-Dist: ofplang-schedule>=0.1.0
|
|
25
|
+
Requires-Dist: ofplang-run>=0.1.0
|
|
26
|
+
Provides-Extra: test
|
|
27
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff>=0.16; extra == "dev"
|
|
31
|
+
Requires-Dist: mypy>=1.11; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# ofplang
|
|
35
|
+
|
|
36
|
+
[](https://github.com/ofplang/ofp/actions/workflows/ci.yml)
|
|
37
|
+
[](https://pypi.org/project/ofplang/)
|
|
38
|
+
|
|
39
|
+
The umbrella **`ofp`** command-line interface for the **Object-flow Programming
|
|
40
|
+
Language** toolchain. Installing this one package pulls in the whole toolchain
|
|
41
|
+
and exposes it under a single command:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
ofp validate ... # check a workflow is well-formed portable v0
|
|
45
|
+
ofp schedule ... # compute a schedule for a workflow
|
|
46
|
+
ofp run ... # execute a workflow (rolling-horizon runner / simulator)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The language is defined in the [ofplang/spec](https://github.com/ofplang/spec)
|
|
50
|
+
repository.
|
|
51
|
+
|
|
52
|
+
## Install
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
pip install ofplang
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Requires Python 3.10+. This package is a thin dispatcher; it depends on the
|
|
59
|
+
sibling packages that do the work:
|
|
60
|
+
|
|
61
|
+
- [`ofplang-validate`](https://github.com/ofplang/validate) — the validator
|
|
62
|
+
- [`ofplang-schedule`](https://github.com/ofplang/schedule) — the scheduler
|
|
63
|
+
- [`ofplang-run`](https://github.com/ofplang/run) — the runner / simulator
|
|
64
|
+
|
|
65
|
+
## Command line
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
ofp <command> [options] # or: python -m ofplang.ofp <command> [options]
|
|
69
|
+
ofp <command> --help # command-specific options
|
|
70
|
+
ofp --version
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`ofp` forwards each subcommand to the corresponding sibling CLI **in-process**,
|
|
74
|
+
so every command keeps its own options, output, and exit codes. `ofp` itself
|
|
75
|
+
adds only routing and a top-level `--help`/`--version`.
|
|
76
|
+
|
|
77
|
+
Each sibling also installs its own standalone command (`ofp-validate`,
|
|
78
|
+
`ofp-schedule`, `ofp-run`); `ofp <command>` is the convenience aggregator.
|
|
79
|
+
|
|
80
|
+
Exit codes: `2` for an unknown/missing command or usage error at the `ofp`
|
|
81
|
+
level; otherwise the subcommand's own exit code is returned unchanged.
|
|
82
|
+
|
|
83
|
+
## Scope
|
|
84
|
+
|
|
85
|
+
This repository contains only the dispatcher. Behavior, options, and semantics
|
|
86
|
+
live in the sibling repositories linked above. The package is published to PyPI
|
|
87
|
+
as `ofplang`; the `ofplang` import namespace is a PEP 420 namespace shared
|
|
88
|
+
across the organization's tools, and this distribution provides `ofplang.ofp`.
|
ofplang-0.1.0/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# ofplang
|
|
2
|
+
|
|
3
|
+
[](https://github.com/ofplang/ofp/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/ofplang/)
|
|
5
|
+
|
|
6
|
+
The umbrella **`ofp`** command-line interface for the **Object-flow Programming
|
|
7
|
+
Language** toolchain. Installing this one package pulls in the whole toolchain
|
|
8
|
+
and exposes it under a single command:
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
ofp validate ... # check a workflow is well-formed portable v0
|
|
12
|
+
ofp schedule ... # compute a schedule for a workflow
|
|
13
|
+
ofp run ... # execute a workflow (rolling-horizon runner / simulator)
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The language is defined in the [ofplang/spec](https://github.com/ofplang/spec)
|
|
17
|
+
repository.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pip install ofplang
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Requires Python 3.10+. This package is a thin dispatcher; it depends on the
|
|
26
|
+
sibling packages that do the work:
|
|
27
|
+
|
|
28
|
+
- [`ofplang-validate`](https://github.com/ofplang/validate) — the validator
|
|
29
|
+
- [`ofplang-schedule`](https://github.com/ofplang/schedule) — the scheduler
|
|
30
|
+
- [`ofplang-run`](https://github.com/ofplang/run) — the runner / simulator
|
|
31
|
+
|
|
32
|
+
## Command line
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
ofp <command> [options] # or: python -m ofplang.ofp <command> [options]
|
|
36
|
+
ofp <command> --help # command-specific options
|
|
37
|
+
ofp --version
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`ofp` forwards each subcommand to the corresponding sibling CLI **in-process**,
|
|
41
|
+
so every command keeps its own options, output, and exit codes. `ofp` itself
|
|
42
|
+
adds only routing and a top-level `--help`/`--version`.
|
|
43
|
+
|
|
44
|
+
Each sibling also installs its own standalone command (`ofp-validate`,
|
|
45
|
+
`ofp-schedule`, `ofp-run`); `ofp <command>` is the convenience aggregator.
|
|
46
|
+
|
|
47
|
+
Exit codes: `2` for an unknown/missing command or usage error at the `ofp`
|
|
48
|
+
level; otherwise the subcommand's own exit code is returned unchanged.
|
|
49
|
+
|
|
50
|
+
## Scope
|
|
51
|
+
|
|
52
|
+
This repository contains only the dispatcher. Behavior, options, and semantics
|
|
53
|
+
live in the sibling repositories linked above. The package is published to PyPI
|
|
54
|
+
as `ofplang`; the `ofplang` import namespace is a PEP 420 namespace shared
|
|
55
|
+
across the organization's tools, and this distribution provides `ofplang.ofp`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""ofplang.ofp -- the umbrella ``ofp`` CLI that dispatches to the toolchain."""
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""Enable ``python -m ofplang.ofp <command> ...``.
|
|
2
|
+
|
|
3
|
+
Intent: mirror the console-script entry point so the CLI is reachable without an
|
|
4
|
+
installed script, which is convenient in dev checkouts and CI.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from ofplang.ofp.cli import main
|
|
8
|
+
|
|
9
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""Umbrella ``ofp`` command-line interface.
|
|
2
|
+
|
|
3
|
+
``ofp`` is a thin dispatcher over the Object-flow Programming Language toolchain.
|
|
4
|
+
It forwards each subcommand to a sibling package's own CLI, in-process::
|
|
5
|
+
|
|
6
|
+
ofp validate ... -> ofplang.validate.cli.main
|
|
7
|
+
ofp schedule ... -> ofplang.schedule.cli.main
|
|
8
|
+
ofp run ... -> ofplang.run.cli.main
|
|
9
|
+
|
|
10
|
+
Each subcommand keeps its own options, exit codes, and ``--help``; ``ofp`` adds
|
|
11
|
+
no behavior of its own beyond routing plus a top-level ``--help``/``--version``.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import importlib
|
|
17
|
+
import sys
|
|
18
|
+
from collections.abc import Sequence
|
|
19
|
+
|
|
20
|
+
# Subcommand -> dotted path of the sibling CLI module exposing ``main(argv)``.
|
|
21
|
+
# Kept as strings so each sibling is imported lazily, only when its subcommand is
|
|
22
|
+
# invoked: ``ofp --help`` need not import a scheduler's ortools/numpy stack, and a
|
|
23
|
+
# subcommand fails with a clear message if its package is somehow missing.
|
|
24
|
+
_SUBCOMMANDS: dict[str, str] = {
|
|
25
|
+
"validate": "ofplang.validate.cli",
|
|
26
|
+
"schedule": "ofplang.schedule.cli",
|
|
27
|
+
"run": "ofplang.run.cli",
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_USAGE = """\
|
|
31
|
+
usage: ofp <command> [options]
|
|
32
|
+
|
|
33
|
+
The umbrella CLI for the Object-flow Programming Language toolchain.
|
|
34
|
+
|
|
35
|
+
commands:
|
|
36
|
+
validate check a workflow document is well-formed portable v0
|
|
37
|
+
schedule compute a schedule for a workflow
|
|
38
|
+
run execute a workflow (rolling-horizon runner / simulator)
|
|
39
|
+
|
|
40
|
+
Run `ofp <command> --help` for command-specific options.
|
|
41
|
+
|
|
42
|
+
options:
|
|
43
|
+
-h, --help show this help and exit
|
|
44
|
+
-V, --version show version and exit
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _version() -> str:
|
|
49
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
50
|
+
|
|
51
|
+
try:
|
|
52
|
+
return version("ofplang")
|
|
53
|
+
except PackageNotFoundError: # editable/source tree without installed metadata
|
|
54
|
+
return "0+unknown"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
58
|
+
args = list(sys.argv[1:] if argv is None else argv)
|
|
59
|
+
|
|
60
|
+
if not args:
|
|
61
|
+
sys.stderr.write(_USAGE)
|
|
62
|
+
return 2
|
|
63
|
+
|
|
64
|
+
head = args[0]
|
|
65
|
+
if head in ("-h", "--help"):
|
|
66
|
+
sys.stdout.write(_USAGE)
|
|
67
|
+
return 0
|
|
68
|
+
if head in ("-V", "--version"):
|
|
69
|
+
sys.stdout.write(f"ofp {_version()}\n")
|
|
70
|
+
return 0
|
|
71
|
+
if head.startswith("-"):
|
|
72
|
+
sys.stderr.write(f"ofp: unrecognized option {head!r}\n\n")
|
|
73
|
+
sys.stderr.write(_USAGE)
|
|
74
|
+
return 2
|
|
75
|
+
|
|
76
|
+
module_path = _SUBCOMMANDS.get(head)
|
|
77
|
+
if module_path is None:
|
|
78
|
+
sys.stderr.write(f"ofp: unknown command {head!r}\n\n")
|
|
79
|
+
sys.stderr.write(_USAGE)
|
|
80
|
+
return 2
|
|
81
|
+
|
|
82
|
+
try:
|
|
83
|
+
module = importlib.import_module(module_path)
|
|
84
|
+
except ImportError as exc:
|
|
85
|
+
sys.stderr.write(
|
|
86
|
+
f"ofp: the '{head}' command requires a package that is not installed "
|
|
87
|
+
f"({exc}).\n"
|
|
88
|
+
)
|
|
89
|
+
return 2
|
|
90
|
+
|
|
91
|
+
exit_code: int = module.main(args[1:])
|
|
92
|
+
return exit_code
|
|
File without changes
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ofplang
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Umbrella `ofp` command-line interface for the Object-flow Programming Language toolchain.
|
|
5
|
+
Author-email: Kazunari Kaizu <kwaizu@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ofplang/ofp
|
|
8
|
+
Project-URL: Repository, https://github.com/ofplang/ofp
|
|
9
|
+
Keywords: ofplang,dataflow,workflow,cli
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: ofplang-validate>=0.1.0
|
|
24
|
+
Requires-Dist: ofplang-schedule>=0.1.0
|
|
25
|
+
Requires-Dist: ofplang-run>=0.1.0
|
|
26
|
+
Provides-Extra: test
|
|
27
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff>=0.16; extra == "dev"
|
|
31
|
+
Requires-Dist: mypy>=1.11; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# ofplang
|
|
35
|
+
|
|
36
|
+
[](https://github.com/ofplang/ofp/actions/workflows/ci.yml)
|
|
37
|
+
[](https://pypi.org/project/ofplang/)
|
|
38
|
+
|
|
39
|
+
The umbrella **`ofp`** command-line interface for the **Object-flow Programming
|
|
40
|
+
Language** toolchain. Installing this one package pulls in the whole toolchain
|
|
41
|
+
and exposes it under a single command:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
ofp validate ... # check a workflow is well-formed portable v0
|
|
45
|
+
ofp schedule ... # compute a schedule for a workflow
|
|
46
|
+
ofp run ... # execute a workflow (rolling-horizon runner / simulator)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The language is defined in the [ofplang/spec](https://github.com/ofplang/spec)
|
|
50
|
+
repository.
|
|
51
|
+
|
|
52
|
+
## Install
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
pip install ofplang
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Requires Python 3.10+. This package is a thin dispatcher; it depends on the
|
|
59
|
+
sibling packages that do the work:
|
|
60
|
+
|
|
61
|
+
- [`ofplang-validate`](https://github.com/ofplang/validate) — the validator
|
|
62
|
+
- [`ofplang-schedule`](https://github.com/ofplang/schedule) — the scheduler
|
|
63
|
+
- [`ofplang-run`](https://github.com/ofplang/run) — the runner / simulator
|
|
64
|
+
|
|
65
|
+
## Command line
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
ofp <command> [options] # or: python -m ofplang.ofp <command> [options]
|
|
69
|
+
ofp <command> --help # command-specific options
|
|
70
|
+
ofp --version
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`ofp` forwards each subcommand to the corresponding sibling CLI **in-process**,
|
|
74
|
+
so every command keeps its own options, output, and exit codes. `ofp` itself
|
|
75
|
+
adds only routing and a top-level `--help`/`--version`.
|
|
76
|
+
|
|
77
|
+
Each sibling also installs its own standalone command (`ofp-validate`,
|
|
78
|
+
`ofp-schedule`, `ofp-run`); `ofp <command>` is the convenience aggregator.
|
|
79
|
+
|
|
80
|
+
Exit codes: `2` for an unknown/missing command or usage error at the `ofp`
|
|
81
|
+
level; otherwise the subcommand's own exit code is returned unchanged.
|
|
82
|
+
|
|
83
|
+
## Scope
|
|
84
|
+
|
|
85
|
+
This repository contains only the dispatcher. Behavior, options, and semantics
|
|
86
|
+
live in the sibling repositories linked above. The package is published to PyPI
|
|
87
|
+
as `ofplang`; the `ofplang` import namespace is a PEP 420 namespace shared
|
|
88
|
+
across the organization's tools, and this distribution provides `ofplang.ofp`.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.gitignore
|
|
2
|
+
LICENSE
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
.github/workflows/ci.yml
|
|
6
|
+
.github/workflows/publish.yml
|
|
7
|
+
ofplang.egg-info/PKG-INFO
|
|
8
|
+
ofplang.egg-info/SOURCES.txt
|
|
9
|
+
ofplang.egg-info/dependency_links.txt
|
|
10
|
+
ofplang.egg-info/entry_points.txt
|
|
11
|
+
ofplang.egg-info/requires.txt
|
|
12
|
+
ofplang.egg-info/scm_file_list.json
|
|
13
|
+
ofplang.egg-info/scm_version.json
|
|
14
|
+
ofplang.egg-info/top_level.txt
|
|
15
|
+
ofplang/ofp/__init__.py
|
|
16
|
+
ofplang/ofp/__main__.py
|
|
17
|
+
ofplang/ofp/cli.py
|
|
18
|
+
ofplang/ofp/py.typed
|
|
19
|
+
tests/test_cli.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
"pyproject.toml",
|
|
4
|
+
"LICENSE",
|
|
5
|
+
"README.md",
|
|
6
|
+
".gitignore",
|
|
7
|
+
".github/workflows/ci.yml",
|
|
8
|
+
".github/workflows/publish.yml",
|
|
9
|
+
"tests/test_cli.py",
|
|
10
|
+
"ofplang/ofp/py.typed",
|
|
11
|
+
"ofplang/ofp/__init__.py",
|
|
12
|
+
"ofplang/ofp/cli.py",
|
|
13
|
+
"ofplang/ofp/__main__.py"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ofplang
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "setuptools-scm>=8"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ofplang"
|
|
7
|
+
description = "Umbrella `ofp` command-line interface for the Object-flow Programming Language toolchain."
|
|
8
|
+
requires-python = ">=3.10"
|
|
9
|
+
dynamic = ["version"]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Kazunari Kaizu", email = "kwaizu@gmail.com" }]
|
|
14
|
+
keywords = ["ofplang", "dataflow", "workflow", "cli"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Software Development :: Compilers",
|
|
25
|
+
"Typing :: Typed",
|
|
26
|
+
]
|
|
27
|
+
# This distribution is a thin dispatcher: it bundles the toolchain by depending
|
|
28
|
+
# on the sibling packages and forwards each subcommand to their CLIs in-process.
|
|
29
|
+
# Siblings are resolved from PyPI; the lower bound matches the sibling-to-sibling
|
|
30
|
+
# convention (`>=0.1.0`).
|
|
31
|
+
dependencies = [
|
|
32
|
+
"ofplang-validate>=0.1.0",
|
|
33
|
+
"ofplang-schedule>=0.1.0",
|
|
34
|
+
"ofplang-run>=0.1.0",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://github.com/ofplang/ofp"
|
|
39
|
+
Repository = "https://github.com/ofplang/ofp"
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
test = ["pytest>=7.0"]
|
|
43
|
+
dev = ["pytest>=7.0", "ruff>=0.16", "mypy>=1.11"]
|
|
44
|
+
|
|
45
|
+
[project.scripts]
|
|
46
|
+
# The umbrella command. Subcommands (`ofp validate|schedule|run`) forward to the
|
|
47
|
+
# sibling packages' own CLIs; those also ship standalone `ofp-*` commands.
|
|
48
|
+
ofp = "ofplang.ofp.cli:main"
|
|
49
|
+
|
|
50
|
+
# Version is derived from git tags (e.g. `v0.1.0`) by setuptools-scm; there is no
|
|
51
|
+
# static version in this file.
|
|
52
|
+
[tool.setuptools_scm]
|
|
53
|
+
|
|
54
|
+
# `ofplang` is a PEP 420 namespace shared across the org's repos (validate,
|
|
55
|
+
# schedule, run, …); this distribution provides only the `ofplang.ofp` package
|
|
56
|
+
# (the dispatcher) under it.
|
|
57
|
+
[tool.setuptools.packages.find]
|
|
58
|
+
include = ["ofplang*"]
|
|
59
|
+
namespaces = true
|
|
60
|
+
|
|
61
|
+
# Ship the PEP 561 marker so downstreams see this package as typed.
|
|
62
|
+
[tool.setuptools.package-data]
|
|
63
|
+
"ofplang.ofp" = ["py.typed"]
|
|
64
|
+
|
|
65
|
+
[tool.pytest.ini_options]
|
|
66
|
+
testpaths = ["tests"]
|
|
67
|
+
pythonpath = ["."]
|
|
68
|
+
addopts = "-ra"
|
|
69
|
+
|
|
70
|
+
[tool.ruff]
|
|
71
|
+
line-length = 100
|
|
72
|
+
target-version = "py310"
|
|
73
|
+
|
|
74
|
+
[tool.ruff.lint]
|
|
75
|
+
select = ["E", "F", "I", "UP", "B", "SIM", "C4", "W"]
|
|
76
|
+
|
|
77
|
+
[tool.mypy]
|
|
78
|
+
python_version = "3.10"
|
|
79
|
+
files = ["ofplang"]
|
|
80
|
+
# `ofplang` is a PEP 420 namespace package (no __init__.py), so tell mypy how to
|
|
81
|
+
# root it rather than letting it guess module names.
|
|
82
|
+
namespace_packages = true
|
|
83
|
+
explicit_package_bases = true
|
|
84
|
+
mypy_path = "."
|
|
85
|
+
ignore_missing_imports = true
|
|
86
|
+
warn_unused_ignores = true
|
|
87
|
+
warn_redundant_casts = true
|
ofplang-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Behavioral tests for the umbrella dispatcher.
|
|
2
|
+
|
|
3
|
+
These exercise only `ofp`-level routing; each subcommand's behavior is covered in
|
|
4
|
+
its own sibling repository. `validate` is used as the dispatch probe because it
|
|
5
|
+
is the lightest sibling (PyYAML only, no ortools/numpy).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
from ofplang.ofp.cli import main
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_no_args_is_usage_error(capsys: pytest.CaptureFixture[str]) -> None:
|
|
16
|
+
assert main([]) == 2
|
|
17
|
+
assert "usage: ofp" in capsys.readouterr().err
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_help_goes_to_stdout_and_succeeds(capsys: pytest.CaptureFixture[str]) -> None:
|
|
21
|
+
assert main(["--help"]) == 0
|
|
22
|
+
out = capsys.readouterr().out
|
|
23
|
+
assert "usage: ofp" in out
|
|
24
|
+
assert "validate" in out and "schedule" in out and "run" in out
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_version(capsys: pytest.CaptureFixture[str]) -> None:
|
|
28
|
+
assert main(["--version"]) == 0
|
|
29
|
+
assert capsys.readouterr().out.startswith("ofp ")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_unknown_command_is_usage_error(capsys: pytest.CaptureFixture[str]) -> None:
|
|
33
|
+
assert main(["frobnicate"]) == 2
|
|
34
|
+
assert "unknown command" in capsys.readouterr().err
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_unrecognized_option_is_usage_error(capsys: pytest.CaptureFixture[str]) -> None:
|
|
38
|
+
assert main(["--nope"]) == 2
|
|
39
|
+
assert "unrecognized option" in capsys.readouterr().err
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_dispatches_to_subcommand() -> None:
|
|
43
|
+
# A missing path is the validator's own usage error (exit 2), returned as a
|
|
44
|
+
# plain int; proves routing reaches the sibling and its exit code passes
|
|
45
|
+
# through unchanged. (`validate --help` would instead raise SystemExit from
|
|
46
|
+
# argparse, which is correct at runtime but awkward to assert on here.)
|
|
47
|
+
assert main(["validate", "no-such-file.yaml"]) == 2
|