mirror of
https://github.com/vale981/two_qubit_model
synced 2025-03-04 17:21:43 -05:00
allow removing models from db
This commit is contained in:
parent
f7b31ed5b8
commit
9160b4af38
1 changed files with 11 additions and 1 deletions
|
@ -247,6 +247,16 @@ def import_results(
|
|||
db[current_hash] = data
|
||||
|
||||
|
||||
def remove_models_from_db(models: list[Model], data_path: str = "./.data"):
|
||||
hashes_to_remove = [model.hexhash for model in models]
|
||||
|
||||
with model_db(data_path) as db:
|
||||
for hash in list(db.keys()):
|
||||
if hash in hashes_to_remove:
|
||||
logging.warning(f"Deleting model '{hash}'.")
|
||||
del db[hash]
|
||||
|
||||
|
||||
def cleanup(
|
||||
models_to_keep: list[Model], data_path: str = "./.data", preview: bool = True
|
||||
):
|
||||
|
@ -290,7 +300,7 @@ def migrate_db_to_new_hashes(
|
|||
for old_hash in list(db.keys()):
|
||||
data = copy.deepcopy(db[old_hash])
|
||||
new_hash = data["model_config"].hexhash
|
||||
|
||||
print(new_hash == old_hash)
|
||||
del db[old_hash]
|
||||
db[new_hash] = data
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue