Skip to content

Commit

Permalink
FIX: parse json metadata outside of SQL engine
Browse files Browse the repository at this point in the history
  • Loading branch information
genematx committed Aug 9, 2024
1 parent 161fea5 commit d3f1b93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ target/
.DS_Store
*~

#alembic
alembic.ini

#vim
*.swp
*.swo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ def upgrade():
)

# Loop over all nodes that have 'parameters' field, choose and update those related to hdf5 files
condition = sa.text("CAST(nodes.metadata->>'parameters' AS TEXT) != ''")
cursor = connection.execute(
sa.select(nodes.c.id, nodes.c.metadata).filter(condition).select_from(nodes)
)
cursor = connection.execute(sa.select(nodes.c.id, nodes.c.metadata).select_from(nodes))
for _id, _md in cursor:
if "hdf5" in (_md.get("mimetype", "") + _md.get("spec", "")).lower():
if isinstance(_md["parameters"], dict) and (
if isinstance(_md.get("parameters"), dict) and (
"path" in _md["parameters"].keys()
):
_md["parameters"]["dataset"] = _md["parameters"].pop("path")
Expand Down

0 comments on commit d3f1b93

Please sign in to comment.