Compare commits
28 commits
314234fed8
...
158fb1d08b
| Author | SHA1 | Date | |
|---|---|---|---|
| 158fb1d08b | |||
| b65ee83698 | |||
|
a5d6b978ea |
|||
|
c2296f00ee |
|||
|
94b677262a |
|||
|
6cfa51f878 |
|||
|
c6f3603fbf |
|||
|
bd581c6c12 |
|||
|
d302ae7e0d |
|||
|
7ce9742ed5 |
|||
|
4853c0e414 |
|||
|
0c01d18ecb |
|||
|
f05caf572d |
|||
|
4a821006ed |
|||
|
53067f7c47 |
|||
|
67a9e4ea4b |
|||
|
ca2eb081bb |
|||
|
0e0153bd1d |
|||
|
54b42040a9 |
|||
|
52f6b0f53c |
|||
|
96731baeb9 |
|||
|
a9cc2b3f48 |
|||
|
6b2db911bf |
|||
|
b51a69bc69 |
|||
|
b2ac8939a3 |
|||
|
373f3476c0 |
|||
|
540160c51f |
|||
|
875d7b9461 |
10 changed files with 55 additions and 40 deletions
13
.github/workflows/mypy.yaml
vendored
13
.github/workflows/mypy.yaml
vendored
|
|
@ -8,22 +8,21 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
mypy:
|
mypy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
UV_CACHE_DIR: /tmp/.uv-cache
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install git-annex
|
- name: Install git-annex
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y git-annex
|
sudo apt-get install -y git-annex
|
||||||
- name: Check out the repository
|
- name: Check out the repository
|
||||||
uses: https://github.com/RouxAntoine/checkout@v4.1.8
|
uses: https://github.com/RouxAntoine/checkout@v4.1.8
|
||||||
with:
|
with:
|
||||||
show-progress: true
|
show-progress: true
|
||||||
- name: Install uv
|
- name: Setup python
|
||||||
uses: astral-sh/setup-uv@v7
|
uses: https://github.com/actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: "3.12"
|
||||||
enable-cache: true
|
- name: Install uv
|
||||||
|
uses: https://github.com/astral-sh/setup-uv@v5
|
||||||
- name: Install corrlib
|
- name: Install corrlib
|
||||||
run: uv sync --locked --all-extras --dev --python "3.12"
|
run: uv sync --locked --all-extras --dev --python "3.12"
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
|
|
||||||
13
.github/workflows/pytest.yaml
vendored
13
.github/workflows/pytest.yaml
vendored
|
|
@ -17,9 +17,11 @@ jobs:
|
||||||
- "3.14"
|
- "3.14"
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
UV_CACHE_DIR: /tmp/.uv-cache
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Setup git
|
||||||
|
run: |
|
||||||
|
git config --global user.email "tester@example.com"
|
||||||
|
git config --global user.name "Tester"
|
||||||
- name: Install git-annex
|
- name: Install git-annex
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
|
|
@ -28,11 +30,12 @@ jobs:
|
||||||
uses: https://github.com/RouxAntoine/checkout@v4.1.8
|
uses: https://github.com/RouxAntoine/checkout@v4.1.8
|
||||||
with:
|
with:
|
||||||
show-progress: true
|
show-progress: true
|
||||||
- name: Install uv
|
- name: Setup python
|
||||||
uses: astral-sh/setup-uv@v7
|
uses: https://github.com/actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
enable-cache: true
|
- name: Install uv
|
||||||
|
uses: https://github.com/astral-sh/setup-uv@v5
|
||||||
- name: Install corrlib
|
- name: Install corrlib
|
||||||
run: uv sync --locked --all-extras --dev --python ${{ matrix.python-version }}
|
run: uv sync --locked --all-extras --dev --python ${{ matrix.python-version }}
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
|
|
||||||
10
.github/workflows/ruff.yaml
vendored
10
.github/workflows/ruff.yaml
vendored
|
|
@ -9,8 +9,6 @@ jobs:
|
||||||
ruff:
|
ruff:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
UV_CACHE_DIR: /tmp/.uv-cache
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install git-annex
|
- name: Install git-annex
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -20,10 +18,12 @@ jobs:
|
||||||
uses: https://github.com/RouxAntoine/checkout@v4.1.8
|
uses: https://github.com/RouxAntoine/checkout@v4.1.8
|
||||||
with:
|
with:
|
||||||
show-progress: true
|
show-progress: true
|
||||||
- name: Install uv
|
- name: Setup python
|
||||||
uses: astral-sh/setup-uv@v7
|
uses: https://github.com/actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
enable-cache: true
|
python-version: "3.12"
|
||||||
|
- name: Install uv
|
||||||
|
uses: https://github.com/astral-sh/setup-uv@v5
|
||||||
- name: Install corrlib
|
- name: Install corrlib
|
||||||
run: uv sync --locked --all-extras --dev --python "3.12"
|
run: uv sync --locked --all-extras --dev --python "3.12"
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ from .main import update_aliases
|
||||||
from .meas_io import drop_cache as mio_drop_cache
|
from .meas_io import drop_cache as mio_drop_cache
|
||||||
from .meas_io import load_record as mio_load_record
|
from .meas_io import load_record as mio_load_record
|
||||||
import os
|
import os
|
||||||
|
from pyerrors import Corr
|
||||||
from importlib.metadata import version
|
from importlib.metadata import version
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -38,7 +39,7 @@ def update(
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def list(
|
def lister(
|
||||||
path: str = typer.Option(
|
path: str = typer.Option(
|
||||||
str('./corrlib'),
|
str('./corrlib'),
|
||||||
"--dataset",
|
"--dataset",
|
||||||
|
|
@ -120,12 +121,14 @@ def stat(
|
||||||
"--dataset",
|
"--dataset",
|
||||||
"-d",
|
"-d",
|
||||||
),
|
),
|
||||||
record: str = typer.Argument(),
|
record_id: str = typer.Argument(),
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Show the statistics of a given record.
|
Show the statistics of a given record.
|
||||||
"""
|
"""
|
||||||
record = mio_load_record(path, record)[0]
|
record = mio_load_record(path, record_id)
|
||||||
|
if isinstance(record, (list, Corr)):
|
||||||
|
record = record[0]
|
||||||
statistics = record.idl
|
statistics = record.idl
|
||||||
print(statistics)
|
print(statistics)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ def _db_lookup(db: str, ensemble: str, correlator_name: str, code: str, project:
|
||||||
|
|
||||||
|
|
||||||
def sfcf_filter(results: pd.DataFrame, **kwargs: Any) -> pd.DataFrame:
|
def sfcf_filter(results: pd.DataFrame, **kwargs: Any) -> pd.DataFrame:
|
||||||
"""
|
r"""
|
||||||
Filter method for the Database entries holding SFCF calculations.
|
Filter method for the Database entries holding SFCF calculations.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|
|
||||||
|
|
@ -320,10 +320,10 @@ def read_data(path: str, project: str, dir_in_project: str, prefix: str, param:
|
||||||
if not param['crr'] == []:
|
if not param['crr'] == []:
|
||||||
if names is not None:
|
if names is not None:
|
||||||
data_crr = pe.input.sfcf.read_sfcf_multi(directory, prefix, param['crr'], param['mrr'], corr_type_list, range(len(param['wf_offsets'])),
|
data_crr = pe.input.sfcf.read_sfcf_multi(directory, prefix, param['crr'], param['mrr'], corr_type_list, range(len(param['wf_offsets'])),
|
||||||
range(len(param['wf_basis'])), range(len(param['wf_basis'])), version, cfg_seperator, keyed_out=True, names=names)
|
range(len(param['wf_basis'])), range(len(param['wf_basis'])), version, cfg_seperator, keyed_out=True, silent=True, names=names)
|
||||||
else:
|
else:
|
||||||
data_crr = pe.input.sfcf.read_sfcf_multi(directory, prefix, param['crr'], param['mrr'], corr_type_list, range(len(param['wf_offsets'])),
|
data_crr = pe.input.sfcf.read_sfcf_multi(directory, prefix, param['crr'], param['mrr'], corr_type_list, range(len(param['wf_offsets'])),
|
||||||
range(len(param['wf_basis'])), range(len(param['wf_basis'])), version, cfg_seperator, keyed_out=True)
|
range(len(param['wf_basis'])), range(len(param['wf_basis'])), version, cfg_seperator, keyed_out=True, silent=True)
|
||||||
for key in data_crr.keys():
|
for key in data_crr.keys():
|
||||||
data[key] = data_crr[key]
|
data[key] = data_crr[key]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import shutil
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def write_measurement(path: str, ensemble: str, measurement: dict[str, dict[str, dict[str, Any]]], uuid: str, code: str, parameter_file: str) -> None:
|
def write_measurement(path: str, ensemble: str, measurement: dict[str, dict[str, dict[str, Any]]], uuid: str, code: str, parameter_file: Union[str, None]) -> None:
|
||||||
"""
|
"""
|
||||||
Write a measurement to the backlog.
|
Write a measurement to the backlog.
|
||||||
If the file for the measurement already exists, update the measurement.
|
If the file for the measurement already exists, update the measurement.
|
||||||
|
|
@ -34,24 +34,33 @@ def write_measurement(path: str, ensemble: str, measurement: dict[str, dict[str,
|
||||||
"""
|
"""
|
||||||
db_file = get_db_file(path)
|
db_file = get_db_file(path)
|
||||||
db = os.path.join(path, db_file)
|
db = os.path.join(path, db_file)
|
||||||
|
|
||||||
|
files_to_save = []
|
||||||
|
|
||||||
get(path, db_file)
|
get(path, db_file)
|
||||||
unlock(path, db_file)
|
unlock(path, db_file)
|
||||||
|
files_to_save.append(db_file)
|
||||||
|
|
||||||
conn = sqlite3.connect(db)
|
conn = sqlite3.connect(db)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
files = []
|
|
||||||
for corr in measurement.keys():
|
for corr in measurement.keys():
|
||||||
file_in_archive = os.path.join('.', 'archive', ensemble, corr, uuid + '.json.gz')
|
file_in_archive = os.path.join('.', 'archive', ensemble, corr, uuid + '.json.gz')
|
||||||
file = os.path.join(path, file_in_archive)
|
file = os.path.join(path, file_in_archive)
|
||||||
files.append(file)
|
|
||||||
known_meas = {}
|
known_meas = {}
|
||||||
if not os.path.exists(os.path.join(path, '.', 'archive', ensemble, corr)):
|
if not os.path.exists(os.path.join(path, '.', 'archive', ensemble, corr)):
|
||||||
os.makedirs(os.path.join(path, '.', 'archive', ensemble, corr))
|
os.makedirs(os.path.join(path, '.', 'archive', ensemble, corr))
|
||||||
|
files_to_save.append(file_in_archive)
|
||||||
else:
|
else:
|
||||||
if os.path.exists(file):
|
if os.path.exists(file):
|
||||||
unlock(path, file_in_archive)
|
if file not in files_to_save:
|
||||||
known_meas = pj.load_json_dict(file)
|
unlock(path, file_in_archive)
|
||||||
|
files_to_save.append(file_in_archive)
|
||||||
|
known_meas = pj.load_json_dict(file, verbose=False)
|
||||||
if code == "sfcf":
|
if code == "sfcf":
|
||||||
parameters = sfcf.read_param(path, uuid, parameter_file)
|
if parameter_file is not None:
|
||||||
|
parameters = sfcf.read_param(path, uuid, parameter_file)
|
||||||
|
else:
|
||||||
|
raise Exception("Need parameter file for this code!")
|
||||||
pars = {}
|
pars = {}
|
||||||
subkeys = list(measurement[corr].keys())
|
subkeys = list(measurement[corr].keys())
|
||||||
for subkey in subkeys:
|
for subkey in subkeys:
|
||||||
|
|
@ -60,7 +69,10 @@ def write_measurement(path: str, ensemble: str, measurement: dict[str, dict[str,
|
||||||
elif code == "openQCD":
|
elif code == "openQCD":
|
||||||
ms_type = list(measurement.keys())[0]
|
ms_type = list(measurement.keys())[0]
|
||||||
if ms_type == 'ms1':
|
if ms_type == 'ms1':
|
||||||
parameters = openQCD.read_ms1_param(path, uuid, parameter_file)
|
if parameter_file is not None:
|
||||||
|
parameters = openQCD.read_ms1_param(path, uuid, parameter_file)
|
||||||
|
else:
|
||||||
|
raise Exception("Need parameter file for this code!")
|
||||||
pars = {}
|
pars = {}
|
||||||
subkeys = []
|
subkeys = []
|
||||||
for i in range(len(parameters["rw_fcts"])):
|
for i in range(len(parameters["rw_fcts"])):
|
||||||
|
|
@ -98,9 +110,8 @@ def write_measurement(path: str, ensemble: str, measurement: dict[str, dict[str,
|
||||||
(corr, ensemble, code, meas_path, uuid, pars[subkey], parameter_file))
|
(corr, ensemble, code, meas_path, uuid, pars[subkey], parameter_file))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
pj.dump_dict_to_json(known_meas, file)
|
pj.dump_dict_to_json(known_meas, file)
|
||||||
files.append(os.path.join(path, db_file))
|
|
||||||
conn.close()
|
conn.close()
|
||||||
save(path, message="Add measurements to database", files=files)
|
save(path, message="Add measurements to database", files=files_to_save)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,6 @@ def import_toml(path: str, file: str, copy_file: bool=True) -> None:
|
||||||
measurement = sfcf.read_data(path, uuid, md['path'], md['prefix'], param,
|
measurement = sfcf.read_data(path, uuid, md['path'], md['prefix'], param,
|
||||||
version=md['version'], cfg_seperator=md['cfg_seperator'], sep='/')
|
version=md['version'], cfg_seperator=md['cfg_seperator'], sep='/')
|
||||||
|
|
||||||
print(mname + " imported.")
|
|
||||||
elif project['code'] == 'openQCD':
|
elif project['code'] == 'openQCD':
|
||||||
if md['measurement'] == 'ms1':
|
if md['measurement'] == 'ms1':
|
||||||
param = openQCD.read_ms1_param(path, uuid, md['param_file'])
|
param = openQCD.read_ms1_param(path, uuid, md['param_file'])
|
||||||
|
|
@ -211,8 +210,8 @@ def import_toml(path: str, file: str, copy_file: bool=True) -> None:
|
||||||
param['type'] = 't1'
|
param['type'] = 't1'
|
||||||
measurement = openQCD.extract_t1(path, uuid, md['path'], param, str(md["prefix"]), int(md["dtr_read"]), int(md["xmin"]), int(md["spatial_extent"]),
|
measurement = openQCD.extract_t1(path, uuid, md['path'], param, str(md["prefix"]), int(md["dtr_read"]), int(md["xmin"]), int(md["spatial_extent"]),
|
||||||
fit_range=int(md.get('fit_range', 5)), postfix=str(md.get('postfix', '')), names=md.get('names', []), files=md.get('files', []))
|
fit_range=int(md.get('fit_range', 5)), postfix=str(md.get('postfix', '')), names=md.get('names', []), files=md.get('files', []))
|
||||||
|
write_measurement(path, ensemble, measurement, uuid, project['code'], (md['param_file'] if 'param_file' in md else None))
|
||||||
write_measurement(path, ensemble, measurement, uuid, project['code'], (md['param_file'] if 'param_file' in md else ''))
|
print(mname + " imported.")
|
||||||
|
|
||||||
if not os.path.exists(os.path.join(path, "toml_imports", uuid)):
|
if not os.path.exists(os.path.join(path, "toml_imports", uuid)):
|
||||||
os.makedirs(os.path.join(path, "toml_imports", uuid))
|
os.makedirs(os.path.join(path, "toml_imports", uuid))
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ def unlock(path: str, file: str) -> None:
|
||||||
"""
|
"""
|
||||||
tracker = get_tracker(path)
|
tracker = get_tracker(path)
|
||||||
if tracker == 'datalad':
|
if tracker == 'datalad':
|
||||||
dl.unlock(file, dataset=path)
|
dl.unlock(os.path.join(path, file), dataset=path)
|
||||||
elif tracker == 'None':
|
elif tracker == 'None':
|
||||||
Warning("Tracker 'None' does not implement unlock.")
|
Warning("Tracker 'None' does not implement unlock.")
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ def test_init_db(tmp_path):
|
||||||
table_names = [table[0] for table in tables]
|
table_names = [table[0] for table in tables]
|
||||||
for expected_table in expected_tables:
|
for expected_table in expected_tables:
|
||||||
assert expected_table in table_names
|
assert expected_table in table_names
|
||||||
|
|
||||||
cursor.execute("SELECT * FROM projects;")
|
cursor.execute("SELECT * FROM projects;")
|
||||||
projects = cursor.fetchall()
|
projects = cursor.fetchall()
|
||||||
assert len(projects) == 0
|
assert len(projects) == 0
|
||||||
|
|
@ -60,7 +60,7 @@ def test_init_db(tmp_path):
|
||||||
project_column_names = [col[1] for col in project_columns]
|
project_column_names = [col[1] for col in project_columns]
|
||||||
for expected_col in expected_project_columns:
|
for expected_col in expected_project_columns:
|
||||||
assert expected_col in project_column_names
|
assert expected_col in project_column_names
|
||||||
|
|
||||||
cursor.execute("PRAGMA table_info('backlogs');")
|
cursor.execute("PRAGMA table_info('backlogs');")
|
||||||
backlog_columns = cursor.fetchall()
|
backlog_columns = cursor.fetchall()
|
||||||
expected_backlog_columns = [
|
expected_backlog_columns = [
|
||||||
|
|
@ -85,7 +85,7 @@ def test_list(tmp_path):
|
||||||
dataset_path = tmp_path / "test_dataset"
|
dataset_path = tmp_path / "test_dataset"
|
||||||
result = runner.invoke(app, ["init", "--dataset", str(dataset_path)])
|
result = runner.invoke(app, ["init", "--dataset", str(dataset_path)])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
result = runner.invoke(app, ["list", "--dataset", str(dataset_path), "ensembles"])
|
result = runner.invoke(app, ["lister", "--dataset", str(dataset_path), "ensembles"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
result = runner.invoke(app, ["list", "--dataset", str(dataset_path), "projects"])
|
result = runner.invoke(app, ["lister", "--dataset", str(dataset_path), "projects"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue