methodic-research 0.36.0__tar.gz → 0.37.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.
- {methodic_research-0.36.0/src/methodic_research.egg-info → methodic_research-0.37.0}/PKG-INFO +1 -1
- {methodic_research-0.36.0 → methodic_research-0.37.0}/pyproject.toml +1 -1
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/__init__.py +2 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/experiments.py +65 -3
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/types.py +40 -2
- {methodic_research-0.36.0 → methodic_research-0.37.0/src/methodic_research.egg-info}/PKG-INFO +1 -1
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_experiments.py +96 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/LICENSE +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/README.md +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/setup.cfg +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/activity.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/api_keys.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/assets.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/chronicle.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/cli.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/collections.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/datasets.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/errata.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/errors.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/feed.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/feedback.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/imports.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/me.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/pending.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/publications.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/reports.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/research_prompts.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/runs.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/search.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/tags.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/transport.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/upload_tracker.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic/variations.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic_research.egg-info/SOURCES.txt +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic_research.egg-info/dependency_links.txt +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic_research.egg-info/entry_points.txt +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic_research.egg-info/requires.txt +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic_research.egg-info/top_level.txt +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_activity.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_api_keys.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_assets.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_cli.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_client.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_collections.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_config.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_datasets.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_distill.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_feed.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_feedback.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_imports.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_pending.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_pending_reasons.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_reports.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_research_prompts.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_runs.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_search.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_upload_tracker.py +0 -0
- {methodic_research-0.36.0 → methodic_research-0.37.0}/tests/test_variations.py +0 -0
|
@@ -8,7 +8,7 @@ name = "methodic-research"
|
|
|
8
8
|
# methodic-lib-publish.yml overwrites this from versions.toml at build
|
|
9
9
|
# time, so the published artifact has a single source of truth. Kept
|
|
10
10
|
# here for local `pip install -e conductor/`.
|
|
11
|
-
version = "0.
|
|
11
|
+
version = "0.37.0"
|
|
12
12
|
description = "Python client for the Chronicle experiment platform"
|
|
13
13
|
requires-python = ">=3.11"
|
|
14
14
|
license = "Apache-2.0"
|
|
@@ -50,6 +50,7 @@ from methodic.types import (
|
|
|
50
50
|
SearchResponse,
|
|
51
51
|
SearchResult,
|
|
52
52
|
SearchScope,
|
|
53
|
+
TentativeParentLink,
|
|
53
54
|
UpstreamRetraction,
|
|
54
55
|
UpstreamRetractionsResponse,
|
|
55
56
|
Variation as VariationData,
|
|
@@ -112,6 +113,7 @@ __all__ = [
|
|
|
112
113
|
"PublicationsAPI",
|
|
113
114
|
"ServerError",
|
|
114
115
|
"TagsAPI",
|
|
116
|
+
"TentativeParentLink",
|
|
115
117
|
"UploadTracker",
|
|
116
118
|
"UpstreamRetraction",
|
|
117
119
|
"UpstreamRetractionsResponse",
|
|
@@ -17,6 +17,7 @@ from methodic.types import (
|
|
|
17
17
|
GitStatus,
|
|
18
18
|
GitToken,
|
|
19
19
|
LineageResponse,
|
|
20
|
+
TentativeParentLink,
|
|
20
21
|
UpstreamRetractionsResponse,
|
|
21
22
|
resolve_organization_id,
|
|
22
23
|
)
|
|
@@ -162,7 +163,28 @@ class ExperimentsAPI:
|
|
|
162
163
|
return
|
|
163
164
|
token = page.next_page_token
|
|
164
165
|
|
|
165
|
-
def commit(
|
|
166
|
+
def commit(
|
|
167
|
+
self,
|
|
168
|
+
experiment_id: str,
|
|
169
|
+
*,
|
|
170
|
+
tentative_links: dict[str, str] | None = None,
|
|
171
|
+
) -> dict[str, Any]:
|
|
172
|
+
"""Commit (lock the spec of) an experiment.
|
|
173
|
+
|
|
174
|
+
If the experiment has **tentative** parent lineage links (from being
|
|
175
|
+
created/forked off a still-``open`` parent — see
|
|
176
|
+
:meth:`tentative_links`), every one must be resolved here or commit
|
|
177
|
+
returns 409: pass ``tentative_links`` mapping each parent experiment id
|
|
178
|
+
to ``"promote"`` (make it real lineage — only valid once the parent has
|
|
179
|
+
committed) or ``"drop"`` (discard the link). Naming a parent that isn't
|
|
180
|
+
a tentative link, or omitting one that is, is rejected — there is no
|
|
181
|
+
silent default.
|
|
182
|
+
"""
|
|
183
|
+
if tentative_links is not None:
|
|
184
|
+
return self._t.put(
|
|
185
|
+
f"/experiments/{experiment_id}/commit",
|
|
186
|
+
json={"tentative_links": tentative_links},
|
|
187
|
+
)
|
|
166
188
|
return self._t.put(f"/experiments/{experiment_id}/commit")
|
|
167
189
|
|
|
168
190
|
def conclude(
|
|
@@ -399,6 +421,33 @@ class ExperimentsAPI:
|
|
|
399
421
|
self._t.get(f"/experiments/{experiment_id}/lineage", params=params or None)
|
|
400
422
|
)
|
|
401
423
|
|
|
424
|
+
def tentative_links(self, experiment_id: str) -> list[TentativeParentLink]:
|
|
425
|
+
"""The experiment's **tentative** parent lineage links.
|
|
426
|
+
|
|
427
|
+
A tentative link is created when an experiment is created/forked off a
|
|
428
|
+
parent that is still ``open`` (uncommitted). It is **excluded from
|
|
429
|
+
lineage reads** (won't show in :meth:`get` ``parent_ids`` or
|
|
430
|
+
:meth:`get_lineage`) and blocks the child's commit until resolved.
|
|
431
|
+
Returns ``[]`` for the common case (no tentative links). Resolve each
|
|
432
|
+
by :meth:`promote_lineage` (once ``promotable``) or by passing a
|
|
433
|
+
``drop``/``promote`` disposition to :meth:`commit`.
|
|
434
|
+
"""
|
|
435
|
+
resp = self._t.get(f"/experiments/{experiment_id}/tentative-links")
|
|
436
|
+
return [
|
|
437
|
+
TentativeParentLink.from_dict(t) for t in resp.get("tentative_links", [])
|
|
438
|
+
]
|
|
439
|
+
|
|
440
|
+
def promote_lineage(self, experiment_id: str, parent_id: str) -> dict[str, Any]:
|
|
441
|
+
"""Promote a tentative parent link to real (explicit) lineage.
|
|
442
|
+
|
|
443
|
+
The deliberate "yes, this fork is real lineage" action: the parent then
|
|
444
|
+
appears in :meth:`get` ``parent_ids`` and the lineage DAG. Requires the
|
|
445
|
+
parent to have **committed** (else 409); a tentative link off a still-
|
|
446
|
+
``open`` parent is not yet promotable. Idempotent — re-promoting an
|
|
447
|
+
already-explicit link succeeds.
|
|
448
|
+
"""
|
|
449
|
+
return self._t.post(f"/experiments/{experiment_id}/lineage/{parent_id}/promote")
|
|
450
|
+
|
|
402
451
|
def git_status(self, experiment_id: str) -> GitStatus:
|
|
403
452
|
"""Current git-integration state for the experiment.
|
|
404
453
|
|
|
@@ -537,8 +586,11 @@ class Experiment:
|
|
|
537
586
|
"""Mint a 1-hour install token scoped to this experiment's repo."""
|
|
538
587
|
return self._chronicle.experiments.mint_git_token(self.id)
|
|
539
588
|
|
|
540
|
-
def commit(self) -> Experiment:
|
|
541
|
-
|
|
589
|
+
def commit(self, *, tentative_links: dict[str, str] | None = None) -> Experiment:
|
|
590
|
+
"""Commit (lock the spec). Pass ``tentative_links`` (parent id →
|
|
591
|
+
``"promote"``/``"drop"``) to resolve any tentative parent links, which
|
|
592
|
+
otherwise block commit. See :meth:`ExperimentsAPI.commit`."""
|
|
593
|
+
self._chronicle.experiments.commit(self.id, tentative_links=tentative_links)
|
|
542
594
|
self._detail = None
|
|
543
595
|
return self
|
|
544
596
|
|
|
@@ -651,6 +703,16 @@ class Experiment:
|
|
|
651
703
|
self.id, direction=direction, depth=depth
|
|
652
704
|
)
|
|
653
705
|
|
|
706
|
+
def tentative_links(self) -> list[TentativeParentLink]:
|
|
707
|
+
"""This experiment's tentative parent lineage links (empty for the
|
|
708
|
+
common case). See :meth:`ExperimentsAPI.tentative_links`."""
|
|
709
|
+
return self._chronicle.experiments.tentative_links(self.id)
|
|
710
|
+
|
|
711
|
+
def promote_lineage(self, parent_id: str) -> dict[str, Any]:
|
|
712
|
+
"""Promote a tentative parent link to real lineage (parent must have
|
|
713
|
+
committed). See :meth:`ExperimentsAPI.promote_lineage`."""
|
|
714
|
+
return self._chronicle.experiments.promote_lineage(self.id, parent_id)
|
|
715
|
+
|
|
654
716
|
def get_upstream_retractions(
|
|
655
717
|
self,
|
|
656
718
|
*,
|
|
@@ -228,17 +228,55 @@ class UpstreamRetractionsResponse:
|
|
|
228
228
|
)
|
|
229
229
|
|
|
230
230
|
|
|
231
|
+
@dataclass
|
|
232
|
+
class TentativeParentLink:
|
|
233
|
+
"""One **tentative** parent lineage link — recorded by creating/forking an
|
|
234
|
+
experiment whose parent was still ``open`` (uncommitted) at the time.
|
|
235
|
+
|
|
236
|
+
A tentative link is **excluded from lineage reads** (it does not appear in
|
|
237
|
+
``ExperimentDetail.parent_ids`` or ``experiments.get_lineage``) and the
|
|
238
|
+
child **cannot commit** until every one is resolved — promoted to real
|
|
239
|
+
lineage (only once ``promotable``) or dropped. Surfaced by
|
|
240
|
+
``CreateExperimentResponse.tentative_parents`` and
|
|
241
|
+
``experiments.tentative_links(id)``.
|
|
242
|
+
"""
|
|
243
|
+
|
|
244
|
+
parent_id: str
|
|
245
|
+
parent_state: str
|
|
246
|
+
promotable: bool
|
|
247
|
+
|
|
248
|
+
@classmethod
|
|
249
|
+
def from_dict(cls, data: dict[str, Any]) -> TentativeParentLink:
|
|
250
|
+
return _from_dict(cls, data)
|
|
251
|
+
|
|
252
|
+
|
|
231
253
|
@dataclass
|
|
232
254
|
class CreateExperimentResponse:
|
|
233
|
-
"""`POST /experiments` response: the new experiment plus the always-created variation 0 / run 0.
|
|
255
|
+
"""`POST /experiments` response: the new experiment plus the always-created variation 0 / run 0.
|
|
256
|
+
|
|
257
|
+
``tentative_parents`` is non-empty only when the experiment was created
|
|
258
|
+
with a parent that was still ``open`` — see :class:`TentativeParentLink`.
|
|
259
|
+
Empty for the common (no-parent / committed-parent) case.
|
|
260
|
+
"""
|
|
234
261
|
|
|
235
262
|
experiment_id: str
|
|
236
263
|
variation: int
|
|
237
264
|
run: int
|
|
265
|
+
tentative_parents: list[TentativeParentLink] = dataclasses.field(
|
|
266
|
+
default_factory=list
|
|
267
|
+
)
|
|
238
268
|
|
|
239
269
|
@classmethod
|
|
240
270
|
def from_dict(cls, data: dict[str, Any]) -> CreateExperimentResponse:
|
|
241
|
-
return
|
|
271
|
+
return cls(
|
|
272
|
+
experiment_id=data["experiment_id"],
|
|
273
|
+
variation=data["variation"],
|
|
274
|
+
run=data["run"],
|
|
275
|
+
tentative_parents=[
|
|
276
|
+
TentativeParentLink.from_dict(t)
|
|
277
|
+
for t in data.get("tentative_parents", [])
|
|
278
|
+
],
|
|
279
|
+
)
|
|
242
280
|
|
|
243
281
|
|
|
244
282
|
@dataclass
|
|
@@ -390,6 +390,102 @@ def test_upstream_retractions_full_chain(requests_mock):
|
|
|
390
390
|
assert resp.retractions == []
|
|
391
391
|
|
|
392
392
|
|
|
393
|
+
# --- Tentative lineage links (fork of an open parent) ---
|
|
394
|
+
|
|
395
|
+
def test_create_surfaces_tentative_parents(requests_mock):
|
|
396
|
+
requests_mock.post(
|
|
397
|
+
f"{BASE}/v1/experiments",
|
|
398
|
+
json={
|
|
399
|
+
"experiment_id": EXP,
|
|
400
|
+
"variation": 0,
|
|
401
|
+
"run": 0,
|
|
402
|
+
"tentative_parents": [
|
|
403
|
+
{"parent_id": "p-open", "parent_state": "open", "promotable": False}
|
|
404
|
+
],
|
|
405
|
+
},
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
exp = _chronicle().experiments.create(
|
|
409
|
+
hypothesis_summary="builds on p-open",
|
|
410
|
+
config_yaml="model: {}\n",
|
|
411
|
+
parent_experiment_ids=["p-open"],
|
|
412
|
+
)
|
|
413
|
+
|
|
414
|
+
links = exp._create_response.tentative_parents
|
|
415
|
+
assert len(links) == 1
|
|
416
|
+
assert links[0].parent_id == "p-open"
|
|
417
|
+
assert links[0].parent_state == "open"
|
|
418
|
+
assert links[0].promotable is False
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
def test_tentative_links_lists_pending_links(requests_mock):
|
|
422
|
+
requests_mock.get(
|
|
423
|
+
f"{BASE}/v1/experiments/{EXP}/tentative-links",
|
|
424
|
+
json={
|
|
425
|
+
"experiment_id": EXP,
|
|
426
|
+
"tentative_links": [
|
|
427
|
+
{"parent_id": "p1", "parent_state": "committed", "promotable": True}
|
|
428
|
+
],
|
|
429
|
+
},
|
|
430
|
+
)
|
|
431
|
+
|
|
432
|
+
links = _chronicle().experiments.tentative_links(EXP)
|
|
433
|
+
|
|
434
|
+
assert requests_mock.last_request.path == f"/v1/experiments/{EXP}/tentative-links"
|
|
435
|
+
assert len(links) == 1
|
|
436
|
+
assert links[0].parent_id == "p1"
|
|
437
|
+
assert links[0].promotable is True
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
def test_promote_lineage_posts_to_promote_route(requests_mock):
|
|
441
|
+
requests_mock.post(
|
|
442
|
+
f"{BASE}/v1/experiments/{EXP}/lineage/p1/promote",
|
|
443
|
+
json={"experiment_id": EXP, "parent_id": "p1", "promoted": True},
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
resp = _chronicle().experiments.promote_lineage(EXP, "p1")
|
|
447
|
+
|
|
448
|
+
assert requests_mock.last_request.path == f"/v1/experiments/{EXP}/lineage/p1/promote"
|
|
449
|
+
assert resp["promoted"] is True
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
def test_commit_sends_tentative_link_resolutions(requests_mock):
|
|
453
|
+
requests_mock.put(f"{BASE}/v1/experiments/{EXP}/commit", json={"committed": True})
|
|
454
|
+
|
|
455
|
+
_chronicle().experiments.commit(
|
|
456
|
+
EXP, tentative_links={"p1": "promote", "p2": "drop"}
|
|
457
|
+
)
|
|
458
|
+
|
|
459
|
+
body = requests_mock.last_request.json()
|
|
460
|
+
assert body["tentative_links"] == {"p1": "promote", "p2": "drop"}
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
def test_commit_without_resolutions_sends_no_body(requests_mock):
|
|
464
|
+
requests_mock.put(f"{BASE}/v1/experiments/{EXP}/commit", json={"committed": True})
|
|
465
|
+
|
|
466
|
+
_chronicle().experiments.commit(EXP)
|
|
467
|
+
|
|
468
|
+
assert requests_mock.last_request.body is None
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
def test_handle_promote_lineage_proxies(requests_mock):
|
|
472
|
+
requests_mock.get(
|
|
473
|
+
f"{BASE}/v1/experiments/{EXP}",
|
|
474
|
+
json=_detail_payload(),
|
|
475
|
+
)
|
|
476
|
+
requests_mock.post(
|
|
477
|
+
f"{BASE}/v1/experiments/{EXP}/lineage/p1/promote",
|
|
478
|
+
json={"experiment_id": EXP, "parent_id": "p1", "promoted": True},
|
|
479
|
+
)
|
|
480
|
+
|
|
481
|
+
exp = _chronicle().experiments.get(EXP)
|
|
482
|
+
from methodic import Experiment
|
|
483
|
+
|
|
484
|
+
handle = Experiment(_chronicle(), EXP, _detail=exp)
|
|
485
|
+
resp = handle.promote_lineage("p1")
|
|
486
|
+
assert resp["promoted"] is True
|
|
487
|
+
|
|
488
|
+
|
|
393
489
|
# --- Variations sub-namespace via handle ---
|
|
394
490
|
|
|
395
491
|
def test_variations_create_through_handle(requests_mock):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic_research.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic_research.egg-info/requires.txt
RENAMED
|
File without changes
|
{methodic_research-0.36.0 → methodic_research-0.37.0}/src/methodic_research.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|