stringforge 0.1.0__py3-none-any.whl
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.
- stringforge/__init__.py +307 -0
- stringforge/cy_io.py +1787 -0
- stringforge/kklt_database.py +2889 -0
- stringforge/lcs_database.py +1223 -0
- stringforge/vacua_writer.py +3079 -0
- stringforge/vacuavault/__init__.py +60 -0
- stringforge/vacuavault/__main__.py +104 -0
- stringforge/vacuavault/catalog.py +222 -0
- stringforge/vacuavault/ci.py +188 -0
- stringforge/vacuavault/curate.py +119 -0
- stringforge/vacuavault/schema.py +459 -0
- stringforge/vulcan/__init__.py +634 -0
- stringforge/vulcan/__main__.py +139 -0
- stringforge/vulcan/certify.py +543 -0
- stringforge/vulcan/community.py +261 -0
- stringforge/vulcan/hf_io.py +296 -0
- stringforge/vulcan/ml_view.py +386 -0
- stringforge/vulcan/ratelimit.py +285 -0
- stringforge/vulcan/reader.py +624 -0
- stringforge/vulcan/runid.py +248 -0
- stringforge/vulcan/schema.py +525 -0
- stringforge/vulcan/snapshot.py +436 -0
- stringforge/vulcan/sync.py +263 -0
- stringforge/vulcan/verifier.py +322 -0
- stringforge/vulcan/writer.py +434 -0
- stringforge-0.1.0.dist-info/METADATA +286 -0
- stringforge-0.1.0.dist-info/RECORD +30 -0
- stringforge-0.1.0.dist-info/WHEEL +5 -0
- stringforge-0.1.0.dist-info/licenses/LICENSE +674 -0
- stringforge-0.1.0.dist-info/top_level.txt +1 -0
stringforge/__init__.py
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# Copyright 2022-2026 Andreas Schachner
|
|
2
|
+
#
|
|
3
|
+
# This file is part of StringForge.
|
|
4
|
+
#
|
|
5
|
+
# StringForge is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# StringForge is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with StringForge. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
"""
|
|
19
|
+
StringForge: shared infrastructure for string-compactification workflows.
|
|
20
|
+
|
|
21
|
+
StringForge provides reproducible access to Calabi-Yau database rows, cache and
|
|
22
|
+
offline workflows, model-loading bridges into physics engines such as JAXVacua,
|
|
23
|
+
and persistent vacua-vault infrastructure with provenance. It is deliberately
|
|
24
|
+
solver-light: flux-vacuum physics lives in JAXVacua, differentiable
|
|
25
|
+
polylogarithms live in JAXPolyLog, and planned packages such as KahlerJAX and
|
|
26
|
+
JAXiverse will consume the same conventions when they are public.
|
|
27
|
+
|
|
28
|
+
Common workflows
|
|
29
|
+
----------------
|
|
30
|
+
|
|
31
|
+
* Query TDF/CICY catalogues without constructing physics models::
|
|
32
|
+
|
|
33
|
+
from stringforge import TDFDatabase
|
|
34
|
+
db = TDFDatabase()
|
|
35
|
+
rows = db.query(h11=3, has_conifolds=True)
|
|
36
|
+
|
|
37
|
+
This pure-I/O layer uses the catalogue convention.
|
|
38
|
+
|
|
39
|
+
* Load catalogue rows as JAXVacua-compatible objects::
|
|
40
|
+
|
|
41
|
+
from stringforge import LCSDatabase
|
|
42
|
+
db = LCSDatabase(dataset="tdf")
|
|
43
|
+
model = db.load_model(ks_id=12345, triang_id=0, h11=128, h12=2)
|
|
44
|
+
|
|
45
|
+
The LCS layer presents Hodge numbers in the mirror convention used by
|
|
46
|
+
``jaxvacua.lcs.lcs_tree``.
|
|
47
|
+
|
|
48
|
+
* Work with the advanced curated KKLT index::
|
|
49
|
+
|
|
50
|
+
from stringforge import KKLTDatabase
|
|
51
|
+
db = KKLTDatabase()
|
|
52
|
+
classes = db.query_classes(ks_id=384564)
|
|
53
|
+
|
|
54
|
+
The ``kklt`` dataset stores conifold-class indices, logical TDF links, and
|
|
55
|
+
curation tags. Actual KKLT vacuum records belong in the shared vault. This
|
|
56
|
+
is an expert workflow, not the default entry point.
|
|
57
|
+
|
|
58
|
+
* Store or curate vacuum solutions with provenance::
|
|
59
|
+
|
|
60
|
+
from stringforge import LCSDatabase, set_vault_dir
|
|
61
|
+
set_vault_dir("./vacua_vault")
|
|
62
|
+
db = LCSDatabase(dataset="tdf")
|
|
63
|
+
# db.designate_vacua(vacua_df, model=model, label="scan")
|
|
64
|
+
|
|
65
|
+
Caching and offline mode
|
|
66
|
+
------------------------
|
|
67
|
+
|
|
68
|
+
Catalogues and parquet shards are downloaded lazily and cached under
|
|
69
|
+
``stringforge.data_dir`` (default ``./.stringforge_cache``; override via
|
|
70
|
+
``STRINGFORGE_DATA_DIR`` or :func:`set_data_dir`). Permanent designated vacua
|
|
71
|
+
live in a separate ``vacua_vault/`` directory (override via
|
|
72
|
+
``STRINGFORGE_VAULT`` or :func:`set_vault_dir`) so cache cleanup does not delete
|
|
73
|
+
curated results. Pass ``offline=True`` to a database constructor, or use
|
|
74
|
+
``from_local(...)``, to disable network access.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
__version__ = "0.1.0"
|
|
78
|
+
|
|
79
|
+
# ── Data directory ────────────────────────────────────────────────────────
|
|
80
|
+
# Default location for database cache files. Override
|
|
81
|
+
# with ``STRINGFORGE_DATA_DIR`` env var or :func:`set_data_dir`. The
|
|
82
|
+
# ``cy_io`` layer reads this global at import time via
|
|
83
|
+
# ``from . import data_dir`` so it must be defined before cy_io's
|
|
84
|
+
# ``DEFAULT_CACHE_DIR`` evaluates.
|
|
85
|
+
import os as _os
|
|
86
|
+
_DEFAULT_DATA_DIR = _os.path.join(_os.getcwd(), ".stringforge_cache")
|
|
87
|
+
data_dir = _os.environ.get("STRINGFORGE_DATA_DIR", _DEFAULT_DATA_DIR)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def set_data_dir(path):
|
|
91
|
+
r"""
|
|
92
|
+
**Description:**
|
|
93
|
+
Set the global data directory for all stringforge database operations
|
|
94
|
+
(HuggingFace cache, vacua storage, designated solutions).
|
|
95
|
+
|
|
96
|
+
New :class:`~stringforge.cy_io.CYDatabase` (and subclass) instances
|
|
97
|
+
created after this call will use the specified directory unless
|
|
98
|
+
overridden by an explicit ``cache_dir`` argument.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
path (str | Path): Absolute or relative path to the data
|
|
102
|
+
directory. The directory is created on first use.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
None
|
|
106
|
+
"""
|
|
107
|
+
global data_dir
|
|
108
|
+
data_dir = str(path)
|
|
109
|
+
# ──────────────────────────────────────────────────────────────────────────
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
# ── Vacua vault directory + HF repo ──────────────────────────────────────
|
|
113
|
+
# Permanent storage for designated vacuum solutions. Resolution order in
|
|
114
|
+
# :func:`stringforge.cy_io._resolve_vault_dir`:
|
|
115
|
+
# 1. ``STRINGFORGE_VAULT`` env var (explicit override), or value set via
|
|
116
|
+
# :func:`set_vault_dir`.
|
|
117
|
+
# 2. ``<repo_root>/vacua_vault/`` when cwd is inside a stringforge
|
|
118
|
+
# source checkout.
|
|
119
|
+
# 3. no fallback; an explicit path is required outside a source checkout.
|
|
120
|
+
# The vault lives outside the cache dir so ``clear_cache()`` never wipes
|
|
121
|
+
# designated solutions.
|
|
122
|
+
|
|
123
|
+
def set_vault_dir(path):
|
|
124
|
+
r"""
|
|
125
|
+
**Description:**
|
|
126
|
+
Set the vault directory for designated vacuum solutions by
|
|
127
|
+
exporting ``STRINGFORGE_VAULT`` into the environment. Takes effect
|
|
128
|
+
for all subsequent database calls.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
path (str | Path | None): Absolute or relative path to the
|
|
132
|
+
vault directory. Pass ``None`` to clear the override and
|
|
133
|
+
fall back to repo-root detection, or raise if no source checkout is found.
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
None
|
|
137
|
+
"""
|
|
138
|
+
if path is None:
|
|
139
|
+
_os.environ.pop("STRINGFORGE_VAULT", None)
|
|
140
|
+
else:
|
|
141
|
+
_os.environ["STRINGFORGE_VAULT"] = str(path)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def set_vault_repo(repo_id):
|
|
145
|
+
r"""
|
|
146
|
+
**Description:**
|
|
147
|
+
Set the HuggingFace dataset repo ID used for uploading / fetching
|
|
148
|
+
community vacuum solutions. Sets the ``STRINGFORGE_VAULT_REPO`` env
|
|
149
|
+
var.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
repo_id (str | None): ``"user/repo"`` on HuggingFace Hub, or
|
|
153
|
+
``None`` to clear the override and fall back to the
|
|
154
|
+
package default ``aschachner/vacua_vault``.
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
None
|
|
158
|
+
"""
|
|
159
|
+
if repo_id is None:
|
|
160
|
+
_os.environ.pop("STRINGFORGE_VAULT_REPO", None)
|
|
161
|
+
else:
|
|
162
|
+
_os.environ["STRINGFORGE_VAULT_REPO"] = str(repo_id)
|
|
163
|
+
# ──────────────────────────────────────────────────────────────────────────
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
# ── Vulcan production-pipeline configuration ─────────────────────────────
|
|
167
|
+
# Vulcan owns the *production* / cluster-side / ML-friendly vacuum repo,
|
|
168
|
+
# complementary to the curated ``vacua_vault`` repo above. Workers stage
|
|
169
|
+
# parquet shards in a local staging directory and a separate sync tier
|
|
170
|
+
# batches them into HuggingFace commits, respecting HF's 100-commits-
|
|
171
|
+
# per-hour cap. See ``stringforge.vulcan`` for the full API.
|
|
172
|
+
|
|
173
|
+
def set_vulcan_repo(repo_id):
|
|
174
|
+
r"""
|
|
175
|
+
**Description:**
|
|
176
|
+
Set the HuggingFace dataset repo ID used by Vulcan for production
|
|
177
|
+
vacuum uploads. Sets the ``STRINGFORGE_VULCAN_REPO`` env var.
|
|
178
|
+
|
|
179
|
+
Args:
|
|
180
|
+
repo_id (str | None): ``"user/repo"`` on HuggingFace Hub, or
|
|
181
|
+
``None`` to clear the override. Vulcan has no implicit
|
|
182
|
+
default repo — each ``Vulcan(repo=...)`` instance must
|
|
183
|
+
be told where to write.
|
|
184
|
+
|
|
185
|
+
Returns:
|
|
186
|
+
None
|
|
187
|
+
"""
|
|
188
|
+
if repo_id is None:
|
|
189
|
+
_os.environ.pop("STRINGFORGE_VULCAN_REPO", None)
|
|
190
|
+
else:
|
|
191
|
+
_os.environ["STRINGFORGE_VULCAN_REPO"] = str(repo_id)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def set_vulcan_staging_dir(path):
|
|
195
|
+
r"""
|
|
196
|
+
**Description:**
|
|
197
|
+
Set the local staging directory used by Vulcan workers for pending
|
|
198
|
+
shards awaiting sync. Sets the ``STRINGFORGE_VULCAN_STAGING_DIR``
|
|
199
|
+
env var.
|
|
200
|
+
|
|
201
|
+
Args:
|
|
202
|
+
path (str | Path | None): Absolute or relative path. Pass
|
|
203
|
+
``None`` to clear the override and fall back to
|
|
204
|
+
``<repo_root>/vulcan_staging/`` or
|
|
205
|
+
``<data_dir>/vulcan_staging/``.
|
|
206
|
+
|
|
207
|
+
Returns:
|
|
208
|
+
None
|
|
209
|
+
"""
|
|
210
|
+
if path is None:
|
|
211
|
+
_os.environ.pop("STRINGFORGE_VULCAN_STAGING_DIR", None)
|
|
212
|
+
else:
|
|
213
|
+
_os.environ["STRINGFORGE_VULCAN_STAGING_DIR"] = str(path)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def set_vulcan_project(project):
|
|
217
|
+
r"""
|
|
218
|
+
**Description:**
|
|
219
|
+
Set the default ``{project}`` substitution for the Vulcan
|
|
220
|
+
run-id template. Sets the ``STRINGFORGE_VULCAN_PROJECT`` env var.
|
|
221
|
+
|
|
222
|
+
Args:
|
|
223
|
+
project (str | None): Project tag. Pass ``None`` to clear.
|
|
224
|
+
|
|
225
|
+
Returns:
|
|
226
|
+
None
|
|
227
|
+
"""
|
|
228
|
+
if project is None:
|
|
229
|
+
_os.environ.pop("STRINGFORGE_VULCAN_PROJECT", None)
|
|
230
|
+
else:
|
|
231
|
+
_os.environ["STRINGFORGE_VULCAN_PROJECT"] = str(project)
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def set_vulcan_token(token):
|
|
235
|
+
r"""
|
|
236
|
+
**Description:**
|
|
237
|
+
Set the HuggingFace access token used by Vulcan's sync tier. Sets
|
|
238
|
+
the ``STRINGFORGE_VULCAN_TOKEN`` env var.
|
|
239
|
+
|
|
240
|
+
Args:
|
|
241
|
+
token (str | None): HuggingFace access token. Pass ``None`` to
|
|
242
|
+
clear the override.
|
|
243
|
+
|
|
244
|
+
Returns:
|
|
245
|
+
None
|
|
246
|
+
"""
|
|
247
|
+
if token is None:
|
|
248
|
+
_os.environ.pop("STRINGFORGE_VULCAN_TOKEN", None)
|
|
249
|
+
else:
|
|
250
|
+
_os.environ["STRINGFORGE_VULCAN_TOKEN"] = str(token)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def set_vulcan_budget(budget):
|
|
254
|
+
r"""
|
|
255
|
+
**Description:**
|
|
256
|
+
Set the commits-per-hour ceiling honoured by Vulcan's sync tier.
|
|
257
|
+
Sets the ``STRINGFORGE_VULCAN_BUDGET`` env var. The hard
|
|
258
|
+
HuggingFace cap is 100/hour; defaults to 90 to leave a safety
|
|
259
|
+
margin.
|
|
260
|
+
|
|
261
|
+
Args:
|
|
262
|
+
budget (int | None): Commits/hour. Pass ``None`` to clear.
|
|
263
|
+
|
|
264
|
+
Returns:
|
|
265
|
+
None
|
|
266
|
+
|
|
267
|
+
Raises:
|
|
268
|
+
ValueError: If ``budget`` is negative.
|
|
269
|
+
"""
|
|
270
|
+
if budget is None:
|
|
271
|
+
_os.environ.pop("STRINGFORGE_VULCAN_BUDGET", None)
|
|
272
|
+
else:
|
|
273
|
+
budget_int = int(budget)
|
|
274
|
+
if budget_int < 0:
|
|
275
|
+
raise ValueError(
|
|
276
|
+
f"Vulcan budget must be non-negative, got {budget_int}."
|
|
277
|
+
)
|
|
278
|
+
from .vulcan.ratelimit import HF_COMMITS_PER_HOUR_CAP
|
|
279
|
+
if budget_int > HF_COMMITS_PER_HOUR_CAP:
|
|
280
|
+
import warnings as _warnings
|
|
281
|
+
_warnings.warn(
|
|
282
|
+
f"Vulcan budget {budget_int} exceeds the HuggingFace "
|
|
283
|
+
f"commits-per-hour cap of {HF_COMMITS_PER_HOUR_CAP}; "
|
|
284
|
+
"uploads above the cap will be throttled or rejected.",
|
|
285
|
+
stacklevel=2,
|
|
286
|
+
)
|
|
287
|
+
_os.environ["STRINGFORGE_VULCAN_BUDGET"] = str(budget_int)
|
|
288
|
+
# ──────────────────────────────────────────────────────────────────────────
|
|
289
|
+
|
|
290
|
+
from .cy_io import *
|
|
291
|
+
from .lcs_database import *
|
|
292
|
+
from .kklt_database import *
|
|
293
|
+
from .vacua_writer import *
|
|
294
|
+
from .vacuavault import *
|
|
295
|
+
from .vulcan import (
|
|
296
|
+
FeatureSpec,
|
|
297
|
+
StagedShard,
|
|
298
|
+
SyncReport,
|
|
299
|
+
Vulcan,
|
|
300
|
+
VulcanMLView,
|
|
301
|
+
VulcanReader,
|
|
302
|
+
resolve_staging_dir,
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
# Optional ecosystem packages are intentionally not imported here. Keeping the
|
|
306
|
+
# package import lightweight avoids solver-library side effects and lets users
|
|
307
|
+
# import ``stringforge`` for pure database/vault workflows.
|