Skip to content

Commit

Permalink
Fix insert_file and add deepdiff
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Sep 30, 2024
1 parent 2d10ecb commit 25e39ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions isimip_publisher/utils/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pathlib import Path
from uuid import uuid4

from deepdiff import DeepDiff
from sqlalchemy import (
BigInteger,
Boolean,
Expand Down Expand Up @@ -417,7 +418,7 @@ def insert_file(session, version, dataset_path, uuid, name, path, size,
raise RuntimeError(f'File {path} is already stored with the same version, but a different checksum')
if file.checksum_type != checksum_type:
raise RuntimeError(f'File {path} is already stored with the same version, but a different checksum_type')
if file.netcdf_header != netcdf_header:
if DeepDiff(file.netcdf_header, netcdf_header, ignore_numeric_type_changes=False):
raise RuntimeError(f'File {path} is already stored with the same version, but a different netcdf_header')
if file.specifiers != specifiers:
raise RuntimeError(f'File {path} is already stored with the same version, but different specifiers')
Expand Down Expand Up @@ -515,7 +516,7 @@ def insert_file_link(session, version, target_file_path, dataset_path,
if file.checksum_type != checksum_type:
raise RuntimeError(f'File link {path} is already stored with the same version,'
' but a different checksum_type')
if file.netcdf_header != netcdf_header:
if DeepDiff(file.netcdf_header, netcdf_header, ignore_numeric_type_changes=False):
raise RuntimeError(f'File link {path} is already stored with the same version,'
' but a different netcdf_header')
if file.specifiers != specifiers:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ classifiers = [
]
dependencies = [
"datacite>=1.1.2",
"deepdiff>=8.0.0",
"isimip-utils>=1.2",
"jsonschema>=3.2.0",
"netCDF4>=1.5.6",
Expand Down

0 comments on commit 25e39ed

Please sign in to comment.