physionlabs 0.1.0rc1__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.
- physionlabs-0.1.0rc1/.github/dependabot.yml +25 -0
- physionlabs-0.1.0rc1/.github/workflows/ci.yml +104 -0
- physionlabs-0.1.0rc1/.github/workflows/publish.yml +106 -0
- physionlabs-0.1.0rc1/.gitignore +9 -0
- physionlabs-0.1.0rc1/LICENSE +202 -0
- physionlabs-0.1.0rc1/NOTICE +4 -0
- physionlabs-0.1.0rc1/PKG-INFO +111 -0
- physionlabs-0.1.0rc1/README.md +87 -0
- physionlabs-0.1.0rc1/openapi/SOURCE +21 -0
- physionlabs-0.1.0rc1/openapi/galileo-v1.yaml +1269 -0
- physionlabs-0.1.0rc1/pyproject.toml +59 -0
- physionlabs-0.1.0rc1/scripts/capture_fixtures.py +121 -0
- physionlabs-0.1.0rc1/scripts/check_contract.py +85 -0
- physionlabs-0.1.0rc1/scripts/generate_models.py +135 -0
- physionlabs-0.1.0rc1/scripts/verify_live.py +185 -0
- physionlabs-0.1.0rc1/src/physionlabs/__init__.py +92 -0
- physionlabs-0.1.0rc1/src/physionlabs/_client.py +79 -0
- physionlabs-0.1.0rc1/src/physionlabs/_poll.py +42 -0
- physionlabs-0.1.0rc1/src/physionlabs/_transport.py +201 -0
- physionlabs-0.1.0rc1/src/physionlabs/errors.py +171 -0
- physionlabs-0.1.0rc1/src/physionlabs/models.py +651 -0
- physionlabs-0.1.0rc1/src/physionlabs/py.typed +0 -0
- physionlabs-0.1.0rc1/src/physionlabs/resources/__init__.py +5 -0
- physionlabs-0.1.0rc1/src/physionlabs/resources/account.py +39 -0
- physionlabs-0.1.0rc1/src/physionlabs/resources/evaluations.py +206 -0
- physionlabs-0.1.0rc1/src/physionlabs/resources/videos.py +142 -0
- physionlabs-0.1.0rc1/tests/__init__.py +0 -0
- physionlabs-0.1.0rc1/tests/conftest.py +81 -0
- physionlabs-0.1.0rc1/tests/fixtures/account.json +33 -0
- physionlabs-0.1.0rc1/tests/fixtures/credits.json +16 -0
- physionlabs-0.1.0rc1/tests/fixtures/evaluation_completed.json +967 -0
- physionlabs-0.1.0rc1/tests/fixtures/evaluation_list.json +972 -0
- physionlabs-0.1.0rc1/tests/fixtures/evaluation_out_of_range.json +1228 -0
- physionlabs-0.1.0rc1/tests/fixtures/models.json +41 -0
- physionlabs-0.1.0rc1/tests/fixtures/quota.json +38 -0
- physionlabs-0.1.0rc1/tests/fixtures/status.json +22 -0
- physionlabs-0.1.0rc1/tests/test_client.py +31 -0
- physionlabs-0.1.0rc1/tests/test_contract_parity.py +97 -0
- physionlabs-0.1.0rc1/tests/test_idempotency.py +96 -0
- physionlabs-0.1.0rc1/tests/test_models.py +87 -0
- physionlabs-0.1.0rc1/tests/test_packaging.py +86 -0
- physionlabs-0.1.0rc1/tests/test_pagination.py +87 -0
- physionlabs-0.1.0rc1/tests/test_transport.py +79 -0
- physionlabs-0.1.0rc1/tests/test_upload.py +123 -0
- physionlabs-0.1.0rc1/uv.lock +1332 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Security updates are enabled through the repository setting (they need no
|
|
2
|
+
# config). This file is the VERSION updates — the routine bumps — kept weekly and
|
|
3
|
+
# grouped, because a public SDK with two ecosystems otherwise files a pull
|
|
4
|
+
# request a day and the security ones get lost among them.
|
|
5
|
+
version: 2
|
|
6
|
+
updates:
|
|
7
|
+
- package-ecosystem: uv
|
|
8
|
+
directory: /
|
|
9
|
+
schedule:
|
|
10
|
+
interval: weekly
|
|
11
|
+
groups:
|
|
12
|
+
# httpx and pydantic are the only RUNTIME dependencies, so they are worth
|
|
13
|
+
# seeing on their own — a bump there changes what a consumer resolves.
|
|
14
|
+
runtime:
|
|
15
|
+
patterns: ["httpx", "pydantic"]
|
|
16
|
+
dev:
|
|
17
|
+
patterns: ["*"]
|
|
18
|
+
exclude-patterns: ["httpx", "pydantic"]
|
|
19
|
+
- package-ecosystem: github-actions
|
|
20
|
+
directory: /
|
|
21
|
+
schedule:
|
|
22
|
+
interval: weekly
|
|
23
|
+
groups:
|
|
24
|
+
actions:
|
|
25
|
+
patterns: ["*"]
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
# So the live job can be re-run against a deployment that has changed without
|
|
8
|
+
# a commit to this repo — which is most of the reason it exists. The API moves
|
|
9
|
+
# on its own schedule; a contract check that can only run when the SDK changes
|
|
10
|
+
# would notice a drift on whatever day someone next touched the SDK.
|
|
11
|
+
workflow_dispatch:
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
matrix:
|
|
18
|
+
python: ["3.10", "3.11", "3.12", "3.13"]
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- uses: astral-sh/setup-uv@v5
|
|
22
|
+
with:
|
|
23
|
+
enable-cache: true
|
|
24
|
+
- run: uv python install ${{ matrix.python }}
|
|
25
|
+
- run: uv sync --frozen
|
|
26
|
+
# Fails if the contract copy was edited here instead of upstream, or if the
|
|
27
|
+
# committed models are not what the contract generates.
|
|
28
|
+
- run: uv run python scripts/check_contract.py
|
|
29
|
+
- run: uv run mypy
|
|
30
|
+
- run: uv run pytest
|
|
31
|
+
|
|
32
|
+
# tests/test_packaging.py checks what pyproject DECLARES; this checks what
|
|
33
|
+
# the wheel actually contains. The two differ in exactly the way that
|
|
34
|
+
# matters: a declaration can be right while the build leaves the file out,
|
|
35
|
+
# and nobody finds out until an install is missing py.typed and every
|
|
36
|
+
# annotation in the package is silently ignored.
|
|
37
|
+
- name: The wheel carries the marker and the license
|
|
38
|
+
run: |
|
|
39
|
+
uv build --wheel
|
|
40
|
+
python - <<'PY'
|
|
41
|
+
import glob, zipfile
|
|
42
|
+
wheel = glob.glob("dist/*.whl")[0]
|
|
43
|
+
names = set(zipfile.ZipFile(wheel).namelist())
|
|
44
|
+
# The dist-info directory carries the VERSION, so it is found rather
|
|
45
|
+
# than spelled out. Written out, this check named `0.1.0` and broke on
|
|
46
|
+
# the first release candidate — pointing at a missing license, which is
|
|
47
|
+
# the wrong thing to go looking at. The same mistake was in
|
|
48
|
+
# publish.yml; it lived in two places and was fixed in one.
|
|
49
|
+
info = next((n.split("/")[0] for n in names if n.endswith(".dist-info/METADATA")), None)
|
|
50
|
+
assert info, f"{wheel} has no dist-info"
|
|
51
|
+
missing = {
|
|
52
|
+
n for n in ("physionlabs/py.typed", f"{info}/licenses/LICENSE", f"{info}/licenses/NOTICE")
|
|
53
|
+
if n not in names
|
|
54
|
+
}
|
|
55
|
+
assert not missing, f"{wheel} is missing {sorted(missing)}"
|
|
56
|
+
leaked = [n for n in names if n.startswith(("tests/", "scripts/", "openapi/"))]
|
|
57
|
+
assert not leaked, f"{wheel} ships {leaked}"
|
|
58
|
+
print(f"{wheel}: {info}, {len(names)} entries, marker and license present")
|
|
59
|
+
PY
|
|
60
|
+
|
|
61
|
+
# Talks to the development deployment. Deliberately NOT required: it fails when
|
|
62
|
+
# that deployment is down or mid-rollout, which is not the pull request's fault
|
|
63
|
+
# — but it is the only check that would notice the API drifting away from the
|
|
64
|
+
# contract, so it runs on every change and is read rather than gated on.
|
|
65
|
+
live:
|
|
66
|
+
runs-on: ubuntu-latest
|
|
67
|
+
continue-on-error: true
|
|
68
|
+
steps:
|
|
69
|
+
- uses: actions/checkout@v4
|
|
70
|
+
- uses: astral-sh/setup-uv@v5
|
|
71
|
+
with:
|
|
72
|
+
enable-cache: true
|
|
73
|
+
- run: uv sync --frozen
|
|
74
|
+
|
|
75
|
+
# Named at the JOB level so a missing key is visible in the run list rather
|
|
76
|
+
# than only in a log nobody opens. Without it the only endpoint this can
|
|
77
|
+
# reach is /v1/status, and a green tick would then mean "the simplest
|
|
78
|
+
# endpoint in the API still answers" while reading as "the contract holds".
|
|
79
|
+
- name: Is there a key to verify with?
|
|
80
|
+
env:
|
|
81
|
+
GALILEO_API_KEY: ${{ secrets.GALILEO_CI_API_KEY }}
|
|
82
|
+
run: |
|
|
83
|
+
if [ -z "$GALILEO_API_KEY" ]; then
|
|
84
|
+
echo "::warning title=Live verification incomplete::GALILEO_CI_API_KEY is not set. Only /v1/status will be checked; evaluations, models and quota will not."
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
# Exit 2 is this script's "INCOMPLETE" — endpoints skipped for want of a
|
|
88
|
+
# key. Distinguished from exit 1, a real mismatch, because the two mean
|
|
89
|
+
# opposite things about the contract and only one is a finding.
|
|
90
|
+
- name: Contract against the live service
|
|
91
|
+
env:
|
|
92
|
+
GALILEO_API_KEY: ${{ secrets.GALILEO_CI_API_KEY }}
|
|
93
|
+
GALILEO_BASE_URL: https://api-dev.physionlabs.ai
|
|
94
|
+
run: |
|
|
95
|
+
set +e
|
|
96
|
+
uv run python scripts/verify_live.py
|
|
97
|
+
code=$?
|
|
98
|
+
set -e
|
|
99
|
+
case "$code" in
|
|
100
|
+
0) echo "::notice title=Contract verified::Every endpoint matched." ;;
|
|
101
|
+
2) echo "::warning title=Contract NOT verified::Skipped for want of GALILEO_CI_API_KEY." ;;
|
|
102
|
+
*) echo "::error title=Contract mismatch::The live service does not match the contract."
|
|
103
|
+
exit 1 ;;
|
|
104
|
+
esac
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
|
|
3
|
+
# DISABLED ON PURPOSE. There is no `push` or `release` trigger: the only way to
|
|
4
|
+
# run this is to dispatch it by hand and type the version, which is the state the
|
|
5
|
+
# review asked for while the release blockers were open.
|
|
6
|
+
#
|
|
7
|
+
# Turning it on later means adding a `release: [published]` trigger. Do that in
|
|
8
|
+
# the same change that removes the guard below, so the two cannot disagree.
|
|
9
|
+
on:
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
inputs:
|
|
12
|
+
version:
|
|
13
|
+
description: >-
|
|
14
|
+
The version to publish. Must match pyproject.toml exactly. A
|
|
15
|
+
prerelease (0.1.0rc1) is fine — PyPI marks it as one, and
|
|
16
|
+
`pip install physionlabs` skips it unless the caller asks with
|
|
17
|
+
--pre or pins it. So there is no dist-tag equivalent to get wrong
|
|
18
|
+
here, unlike npm.
|
|
19
|
+
required: true
|
|
20
|
+
i_have_verified_the_live_contract:
|
|
21
|
+
description: >-
|
|
22
|
+
Type "yes" only if scripts/verify_live.py has been run against a real
|
|
23
|
+
deployment WITH a key and reported no mismatches. Its exit code 2 —
|
|
24
|
+
"INCOMPLETE" — is not a pass.
|
|
25
|
+
required: true
|
|
26
|
+
|
|
27
|
+
permissions:
|
|
28
|
+
contents: read
|
|
29
|
+
# PyPI trusted publishing: the index trusts THIS workflow rather than an API
|
|
30
|
+
# token, and mints the credential from an OIDC exchange. Nothing long-lived
|
|
31
|
+
# exists to leak or rotate.
|
|
32
|
+
#
|
|
33
|
+
# PyPI also accepts a PENDING publisher — configured for a name that does not
|
|
34
|
+
# exist yet — so unlike npm this needs no token even for the FIRST upload.
|
|
35
|
+
# Configure it at pypi.org/manage/account/publishing before dispatching:
|
|
36
|
+
# project physionlabs · owner Physion-Labs · repo galileo-python
|
|
37
|
+
# workflow publish.yml · environment pypi-publish
|
|
38
|
+
id-token: write
|
|
39
|
+
|
|
40
|
+
jobs:
|
|
41
|
+
publish:
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
environment: pypi-publish # a second gate: approvals live on the environment
|
|
44
|
+
steps:
|
|
45
|
+
- uses: actions/checkout@v4
|
|
46
|
+
- uses: astral-sh/setup-uv@v5
|
|
47
|
+
with:
|
|
48
|
+
enable-cache: true
|
|
49
|
+
|
|
50
|
+
- name: Refuse unless the dispatcher confirmed the live check
|
|
51
|
+
env:
|
|
52
|
+
CONFIRMED: ${{ inputs.i_have_verified_the_live_contract }}
|
|
53
|
+
run: |
|
|
54
|
+
if [ "$CONFIRMED" != "yes" ]; then
|
|
55
|
+
echo "::error::A published version cannot be unpublished. Run scripts/verify_live.py with a key first."
|
|
56
|
+
exit 1
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
- name: The version typed must match what pyproject says
|
|
60
|
+
env:
|
|
61
|
+
WANT: ${{ inputs.version }}
|
|
62
|
+
run: |
|
|
63
|
+
have=$(python -c "import tomllib,pathlib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']['version'])")
|
|
64
|
+
if [ "$have" != "$WANT" ]; then
|
|
65
|
+
echo "::error::pyproject.toml is $have, you asked to publish $WANT."
|
|
66
|
+
exit 1
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
- run: uv sync --frozen
|
|
70
|
+
# Everything the required CI does, again, here — a publish that skipped it
|
|
71
|
+
# because "CI was green on the branch" is a publish of a different tree.
|
|
72
|
+
- run: uv run python scripts/check_contract.py
|
|
73
|
+
- run: uv run mypy
|
|
74
|
+
- run: uv run pytest
|
|
75
|
+
|
|
76
|
+
- run: uv build
|
|
77
|
+
# The wheel has to carry the marker and the license, or the install is
|
|
78
|
+
# missing a file its own metadata names. tests/test_packaging.py checks what
|
|
79
|
+
# pyproject DECLARES; this checks what was built.
|
|
80
|
+
- name: The wheel carries the marker and the license
|
|
81
|
+
run: |
|
|
82
|
+
python - <<'PY'
|
|
83
|
+
import glob, re, zipfile
|
|
84
|
+
wheel = glob.glob("dist/*.whl")[0]
|
|
85
|
+
names = set(zipfile.ZipFile(wheel).namelist())
|
|
86
|
+
# The dist-info directory carries the version, so it is FOUND rather
|
|
87
|
+
# than spelled out — an earlier version of this check hardcoded 0.1.0
|
|
88
|
+
# and would have passed vacuously on the first release candidate,
|
|
89
|
+
# looking for a directory that no longer existed.
|
|
90
|
+
info = next((n.split("/")[0] for n in names if n.endswith(".dist-info/METADATA")), None)
|
|
91
|
+
assert info, f"{wheel} has no dist-info"
|
|
92
|
+
missing = {n for n in (
|
|
93
|
+
"physionlabs/py.typed",
|
|
94
|
+
f"{info}/licenses/LICENSE",
|
|
95
|
+
f"{info}/licenses/NOTICE",
|
|
96
|
+
) if n not in names}
|
|
97
|
+
assert not missing, f"{wheel} is missing {sorted(missing)}"
|
|
98
|
+
leaked = [n for n in names if n.startswith(("tests/", "scripts/", "openapi/"))]
|
|
99
|
+
assert not leaked, f"{wheel} ships {leaked}"
|
|
100
|
+
print(f"{wheel}: {info}, marker and license present")
|
|
101
|
+
PY
|
|
102
|
+
|
|
103
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
104
|
+
with:
|
|
105
|
+
# No password: the OIDC exchange above is the credential.
|
|
106
|
+
attestations: true
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: physionlabs
|
|
3
|
+
Version: 0.1.0rc1
|
|
4
|
+
Summary: Official Python client for the Galileo video evaluation API.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Physion-Labs/galileo-python
|
|
6
|
+
Project-URL: Issues, https://github.com/Physion-Labs/galileo-python/issues
|
|
7
|
+
Author-email: Physion Labs <support@physionlabs.ai>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: NOTICE
|
|
11
|
+
Keywords: evaluation,galileo,physion,video
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: httpx>=0.27
|
|
22
|
+
Requires-Dist: pydantic>=2.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# physionlabs
|
|
26
|
+
|
|
27
|
+
Official Python client for the Galileo video evaluation API.
|
|
28
|
+
|
|
29
|
+
> **Not published yet.** This repository is under construction; the package does
|
|
30
|
+
> not exist on PyPI and the API surface below is not final.
|
|
31
|
+
|
|
32
|
+
## What Galileo does
|
|
33
|
+
|
|
34
|
+
Submit a generated video and a prompt; get back the places where the video has
|
|
35
|
+
visual defects and the places where it does not do what the prompt asked.
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from physionlabs import Galileo
|
|
39
|
+
|
|
40
|
+
galileo = Galileo() # reads GALILEO_API_KEY
|
|
41
|
+
|
|
42
|
+
evaluation = galileo.evaluations.create_and_wait(
|
|
43
|
+
prompt="A red ball rolls off a table and bounces twice.",
|
|
44
|
+
video={"url": "https://cdn.example.com/red-ball.mp4"},
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# `result` is None on a failed run, so it is worth branching rather than
|
|
48
|
+
# reaching straight in — a failed evaluation is an outcome, not an exception.
|
|
49
|
+
if evaluation.status.value == "failed":
|
|
50
|
+
print("failed:", evaluation.error.message if evaluation.error else "no reason given")
|
|
51
|
+
else:
|
|
52
|
+
for finding in (evaluation.result.glitches if evaluation.result else []):
|
|
53
|
+
print(finding.type.value, finding.description)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`partial` is also terminal and DOES carry a result: one detector finished and
|
|
57
|
+
another did not, and `detectors` says which of them to trust. A caller waiting
|
|
58
|
+
for `completed` alone waits forever.
|
|
59
|
+
|
|
60
|
+
Uploading a local file instead of pointing at a URL — three calls behind one,
|
|
61
|
+
and the bytes are streamed rather than held in memory:
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
video = galileo.videos.upload("./clip.mp4")
|
|
65
|
+
evaluation = galileo.evaluations.create_and_wait(
|
|
66
|
+
prompt="A red ball rolls off a table and bounces twice.",
|
|
67
|
+
video={"upload_id": video.id},
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Walking a large account, and retrying what failed:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
for ev in galileo.evaluations.iterate(status=["failed"]):
|
|
75
|
+
nxt = galileo.evaluations.retry(ev.id) # idempotent, unlike create
|
|
76
|
+
print(ev.id, "->", nxt.id)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`retry()` is the only idempotent submission in this API: press it in a burst and
|
|
80
|
+
every caller is handed the same successor. `create()` is not, which is why this
|
|
81
|
+
client never retries it — see the note in `resources/evaluations.py`.
|
|
82
|
+
|
|
83
|
+
## The contract
|
|
84
|
+
|
|
85
|
+
This client is not hand-written against a running server. `openapi/galileo-v1.yaml`
|
|
86
|
+
is a copy of the API's OpenAPI description, and the models in
|
|
87
|
+
`physionlabs/models.py` are generated from it — so a field cannot be wrong here
|
|
88
|
+
without being wrong in the contract.
|
|
89
|
+
|
|
90
|
+
`openapi/SOURCE` records which upstream revision the copy is.
|
|
91
|
+
`python scripts/check_contract.py` fails if the copy has been edited locally, or
|
|
92
|
+
if the generated models are not what the contract produces.
|
|
93
|
+
|
|
94
|
+
The Node client, [`@physionlabs/galileo`](https://github.com/Physion-Labs/galileo-node),
|
|
95
|
+
is built from the same copy of the same file.
|
|
96
|
+
|
|
97
|
+
## Development
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
uv sync
|
|
101
|
+
uv run python scripts/generate_models.py # regenerate models from the contract
|
|
102
|
+
uv run python scripts/check_contract.py # verify the copy and the models are in step
|
|
103
|
+
uv run pytest
|
|
104
|
+
uv run mypy
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
[Apache-2.0](LICENSE). Chosen over MIT for the explicit patent grant: MIT is
|
|
110
|
+
silent on patents, which is one more thing for a reviewer to think about, and
|
|
111
|
+
Apache-2.0's retaliation clause protects everyone using it.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# physionlabs
|
|
2
|
+
|
|
3
|
+
Official Python client for the Galileo video evaluation API.
|
|
4
|
+
|
|
5
|
+
> **Not published yet.** This repository is under construction; the package does
|
|
6
|
+
> not exist on PyPI and the API surface below is not final.
|
|
7
|
+
|
|
8
|
+
## What Galileo does
|
|
9
|
+
|
|
10
|
+
Submit a generated video and a prompt; get back the places where the video has
|
|
11
|
+
visual defects and the places where it does not do what the prompt asked.
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from physionlabs import Galileo
|
|
15
|
+
|
|
16
|
+
galileo = Galileo() # reads GALILEO_API_KEY
|
|
17
|
+
|
|
18
|
+
evaluation = galileo.evaluations.create_and_wait(
|
|
19
|
+
prompt="A red ball rolls off a table and bounces twice.",
|
|
20
|
+
video={"url": "https://cdn.example.com/red-ball.mp4"},
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# `result` is None on a failed run, so it is worth branching rather than
|
|
24
|
+
# reaching straight in — a failed evaluation is an outcome, not an exception.
|
|
25
|
+
if evaluation.status.value == "failed":
|
|
26
|
+
print("failed:", evaluation.error.message if evaluation.error else "no reason given")
|
|
27
|
+
else:
|
|
28
|
+
for finding in (evaluation.result.glitches if evaluation.result else []):
|
|
29
|
+
print(finding.type.value, finding.description)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`partial` is also terminal and DOES carry a result: one detector finished and
|
|
33
|
+
another did not, and `detectors` says which of them to trust. A caller waiting
|
|
34
|
+
for `completed` alone waits forever.
|
|
35
|
+
|
|
36
|
+
Uploading a local file instead of pointing at a URL — three calls behind one,
|
|
37
|
+
and the bytes are streamed rather than held in memory:
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
video = galileo.videos.upload("./clip.mp4")
|
|
41
|
+
evaluation = galileo.evaluations.create_and_wait(
|
|
42
|
+
prompt="A red ball rolls off a table and bounces twice.",
|
|
43
|
+
video={"upload_id": video.id},
|
|
44
|
+
)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Walking a large account, and retrying what failed:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
for ev in galileo.evaluations.iterate(status=["failed"]):
|
|
51
|
+
nxt = galileo.evaluations.retry(ev.id) # idempotent, unlike create
|
|
52
|
+
print(ev.id, "->", nxt.id)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`retry()` is the only idempotent submission in this API: press it in a burst and
|
|
56
|
+
every caller is handed the same successor. `create()` is not, which is why this
|
|
57
|
+
client never retries it — see the note in `resources/evaluations.py`.
|
|
58
|
+
|
|
59
|
+
## The contract
|
|
60
|
+
|
|
61
|
+
This client is not hand-written against a running server. `openapi/galileo-v1.yaml`
|
|
62
|
+
is a copy of the API's OpenAPI description, and the models in
|
|
63
|
+
`physionlabs/models.py` are generated from it — so a field cannot be wrong here
|
|
64
|
+
without being wrong in the contract.
|
|
65
|
+
|
|
66
|
+
`openapi/SOURCE` records which upstream revision the copy is.
|
|
67
|
+
`python scripts/check_contract.py` fails if the copy has been edited locally, or
|
|
68
|
+
if the generated models are not what the contract produces.
|
|
69
|
+
|
|
70
|
+
The Node client, [`@physionlabs/galileo`](https://github.com/Physion-Labs/galileo-node),
|
|
71
|
+
is built from the same copy of the same file.
|
|
72
|
+
|
|
73
|
+
## Development
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
uv sync
|
|
77
|
+
uv run python scripts/generate_models.py # regenerate models from the contract
|
|
78
|
+
uv run python scripts/check_contract.py # verify the copy and the models are in step
|
|
79
|
+
uv run pytest
|
|
80
|
+
uv run mypy
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
[Apache-2.0](LICENSE). Chosen over MIT for the explicit patent grant: MIT is
|
|
86
|
+
silent on patents, which is one more thing for a reviewer to think about, and
|
|
87
|
+
Apache-2.0's retaliation clause protects everyone using it.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Where this copy of the contract came from.
|
|
2
|
+
#
|
|
3
|
+
# The contract is authored in the private PhysionWebapps repo, which also runs
|
|
4
|
+
# the service it describes -- so that is the only place it can be kept true. This
|
|
5
|
+
# repo holds a copy because a public repo cannot submodule a private one without
|
|
6
|
+
# breaking every outside clone and CI run.
|
|
7
|
+
#
|
|
8
|
+
# A copy needs provenance or it becomes folklore. These lines say exactly which
|
|
9
|
+
# upstream revision this file is, so a human syncing it can see at a glance
|
|
10
|
+
# whether they are behind. scripts/check_contract.py verifies the hash still
|
|
11
|
+
# matches, which catches the copy being edited here instead of upstream -- the
|
|
12
|
+
# one change that would make the two silently disagree.
|
|
13
|
+
#
|
|
14
|
+
# The Node client (Physion-Labs/galileo-node) holds the same copy and the same
|
|
15
|
+
# provenance file. When the contract moves, both are synced, or the two SDKs
|
|
16
|
+
# start describing different APIs.
|
|
17
|
+
|
|
18
|
+
repo = Physion-Labs/PhysionWebapps
|
|
19
|
+
commit = b1e615b7e30d0347d1efc6ac2cc9d7f63500b9b6
|
|
20
|
+
path = openapi/galileo-v1.yaml
|
|
21
|
+
sha256 = a69b32d4bf3f01ce9241740376f0c770bc7e02354173487ecb569023734f8717
|