scihist 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.
@@ -0,0 +1,10 @@
1
+ .venv
2
+ .DS_Store
3
+ */*/__pycache__
4
+ others_projects/sciforge
5
+ scistack-gui/extension/node_modules/
6
+ scistack-gui/frontend/node_modules/__pycache__/
7
+ *.pyc
8
+ __pycache__/
9
+ *.pyc
10
+ *.pyo
scihist-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,67 @@
1
+ Metadata-Version: 2.4
2
+ Name: scihist
3
+ Version: 0.1.0
4
+ Summary: Lineage-tracked batch execution for scientific data pipelines
5
+ Author: SciStack Contributors
6
+ License-Expression: MIT
7
+ Keywords: automation,batch,data-science,lineage,pipeline,provenance
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: License :: OSI Approved :: MIT License
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: Topic :: Scientific/Engineering
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.9
20
+ Requires-Dist: scidb>=0.1.0
21
+ Requires-Dist: scilineage>=0.1.0
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
24
+ Requires-Dist: pytest>=7.0; extra == 'dev'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # SciHist
28
+
29
+ Batch execution utilities for data pipelines.
30
+
31
+ Provides utilities for running functions over combinations of metadata, automatically loading inputs and saving outputs.
32
+
33
+ ## Usage
34
+
35
+ ```python
36
+ from scihist import for_each, Fixed
37
+
38
+ for_each(
39
+ process_data,
40
+ inputs={"raw": RawData, "calibration": Fixed(Calibration, session="baseline")},
41
+ outputs=[ProcessedData],
42
+ subject=[1, 2, 3],
43
+ session=["A", "B", "C"],
44
+ )
45
+ ```
46
+
47
+ ### `for_each`
48
+
49
+ Executes a function for all combinations of metadata, loading inputs and saving outputs automatically.
50
+
51
+ ### `Fixed`
52
+
53
+ Wrapper to specify fixed metadata overrides for an input. Use when an input should be loaded with different metadata than the current iteration.
54
+
55
+ ```python
56
+ # Always load baseline from session="BL", regardless of current session
57
+ for_each(
58
+ compare_to_baseline,
59
+ inputs={
60
+ "baseline": Fixed(StepLength, session="BL"),
61
+ "current": StepLength,
62
+ },
63
+ outputs=[Delta],
64
+ subject=[1, 2, 3],
65
+ session=["A", "B", "C"],
66
+ )
67
+ ```
@@ -0,0 +1,41 @@
1
+ # SciHist
2
+
3
+ Batch execution utilities for data pipelines.
4
+
5
+ Provides utilities for running functions over combinations of metadata, automatically loading inputs and saving outputs.
6
+
7
+ ## Usage
8
+
9
+ ```python
10
+ from scihist import for_each, Fixed
11
+
12
+ for_each(
13
+ process_data,
14
+ inputs={"raw": RawData, "calibration": Fixed(Calibration, session="baseline")},
15
+ outputs=[ProcessedData],
16
+ subject=[1, 2, 3],
17
+ session=["A", "B", "C"],
18
+ )
19
+ ```
20
+
21
+ ### `for_each`
22
+
23
+ Executes a function for all combinations of metadata, loading inputs and saving outputs automatically.
24
+
25
+ ### `Fixed`
26
+
27
+ Wrapper to specify fixed metadata overrides for an input. Use when an input should be loaded with different metadata than the current iteration.
28
+
29
+ ```python
30
+ # Always load baseline from session="BL", regardless of current session
31
+ for_each(
32
+ compare_to_baseline,
33
+ inputs={
34
+ "baseline": Fixed(StepLength, session="BL"),
35
+ "current": StepLength,
36
+ },
37
+ outputs=[Delta],
38
+ subject=[1, 2, 3],
39
+ session=["A", "B", "C"],
40
+ )
41
+ ```
@@ -0,0 +1,57 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "scihist"
7
+ version = "0.1.0"
8
+ description = "Lineage-tracked batch execution for scientific data pipelines"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.9"
12
+ authors = [
13
+ { name = "SciStack Contributors" }
14
+ ]
15
+ keywords = [
16
+ "batch",
17
+ "pipeline",
18
+ "lineage",
19
+ "provenance",
20
+ "data-science",
21
+ "automation",
22
+ ]
23
+ classifiers = [
24
+ "Development Status :: 4 - Beta",
25
+ "Intended Audience :: Developers",
26
+ "Intended Audience :: Science/Research",
27
+ "License :: OSI Approved :: MIT License",
28
+ "Operating System :: OS Independent",
29
+ "Programming Language :: Python :: 3",
30
+ "Programming Language :: Python :: 3.10",
31
+ "Programming Language :: Python :: 3.11",
32
+ "Programming Language :: Python :: 3.12",
33
+ "Topic :: Scientific/Engineering",
34
+ "Typing :: Typed",
35
+ ]
36
+ dependencies = [
37
+ "scidb>=0.1.0",
38
+ "scilineage>=0.1.0",
39
+ ]
40
+
41
+ [project.optional-dependencies]
42
+ dev = [
43
+ "pytest>=7.0",
44
+ "pytest-cov>=4.0",
45
+ ]
46
+
47
+ [tool.hatch.build.targets.sdist]
48
+ include = [
49
+ "/src",
50
+ ]
51
+
52
+ [tool.hatch.build.targets.wheel]
53
+ packages = ["src/scihist"]
54
+
55
+ [tool.pytest.ini_options]
56
+ testpaths = ["tests"]
57
+ pythonpath = ["src"]
@@ -0,0 +1,68 @@
1
+ """SciHist: Lineage-tracked batch execution for scientific data pipelines.
2
+
3
+ This package adds lineage tracking on top of scidb. It provides the same
4
+ for_each() interface as scidb, but automatically wraps functions in
5
+ LineageFcn for provenance recording.
6
+
7
+ Example:
8
+ from scihist import for_each, Fixed, configure_database
9
+ from scilineage import lineage_fcn
10
+
11
+ configure_database("experiment.duckdb", ["subject", "session"])
12
+
13
+ @lineage_fcn
14
+ def process_data(raw, calibration):
15
+ return raw * calibration
16
+
17
+ for_each(
18
+ process_data,
19
+ inputs={"raw": RawData, "calibration": Fixed(Calibration, session="baseline")},
20
+ outputs=[ProcessedData],
21
+ subject=[1, 2, 3],
22
+ session=["A", "B", "C"],
23
+ )
24
+ """
25
+
26
+ from .foreach import for_each, save
27
+ from .database import configure_database, find_by_lineage
28
+ from .state import check_combo_state, check_node_state, check_multiple_nodes_state
29
+
30
+ # Re-export DB wrappers from scidb
31
+ from scidb import Fixed, Merge, ColumnSelection, ForEachConfig
32
+
33
+ # Re-export scifor helpers
34
+ from scifor import Col, set_schema, get_schema, PathInput
35
+
36
+ # Re-export scilineage system
37
+ from scilineage import lineage_fcn, LineageFcn, LineageFcnResult, LineageFcnInvocation
38
+
39
+ __version__ = "0.1.0"
40
+
41
+ __all__ = [
42
+ # Core batch execution
43
+ "for_each",
44
+ "save",
45
+ # Configuration
46
+ "configure_database",
47
+ # Lineage query
48
+ "find_by_lineage",
49
+ # Node staleness
50
+ "check_combo_state",
51
+ "check_node_state",
52
+ "check_multiple_nodes_state",
53
+ # DB wrappers
54
+ "Fixed",
55
+ "Merge",
56
+ "ColumnSelection",
57
+ "ForEachConfig",
58
+ "PathInput",
59
+ # Schema helpers
60
+ "Col",
61
+ "set_schema",
62
+ "get_schema",
63
+ # Lineage system
64
+ "lineage_fcn",
65
+ "LineageFcn",
66
+ "LineageFcnResult",
67
+ "LineageFcnInvocation",
68
+ ]
@@ -0,0 +1,51 @@
1
+ """SciHist database configuration — wraps scidb.configure_database with cache backend registration."""
2
+
3
+ from typing import Any
4
+
5
+
6
+ def configure_database(
7
+ db_path: str,
8
+ schema_keys: list[str] | None = None,
9
+ **kwargs,
10
+ ) -> Any:
11
+ """Configure the active database and register it as the lineage cache backend.
12
+
13
+ This is the scihist wrapper around scidb.configure_database(). In addition
14
+ to opening the DuckDB-backed database, it registers the database as the
15
+ cache backend so that lineage-tracked computations can look up previously
16
+ computed results.
17
+
18
+ Args:
19
+ db_path: Path to the DuckDB database file.
20
+ schema_keys: List of metadata keys that form the dataset schema.
21
+ **kwargs: Additional keyword arguments forwarded to scidb.configure_database().
22
+
23
+ Returns:
24
+ The configured DatabaseManager instance.
25
+ """
26
+ from scidb import configure_database as _scidb_configure
27
+ from scilineage import configure_backend
28
+
29
+ db = _scidb_configure(db_path, schema_keys, **kwargs)
30
+ configure_backend(db)
31
+ return db
32
+
33
+
34
+ def find_by_lineage(invocation) -> list | None:
35
+ """Find output values by computation lineage.
36
+
37
+ Given a LineageFcnInvocation (function + inputs), finds any previously
38
+ computed outputs that match by querying the _lineage table via the active
39
+ database.
40
+
41
+ Args:
42
+ invocation: The LineageFcnInvocation computation to look up.
43
+
44
+ Returns:
45
+ List of output values if found, None otherwise.
46
+ """
47
+ from scidb.database import get_database
48
+
49
+ db = get_database()
50
+ lineage_hash = invocation.compute_lineage_hash()
51
+ return db.find_by_lineage_hash(lineage_hash)