Skip to content

Fix issue with uploading - #121

Open
Yannicked wants to merge 1 commit into
iterorganization:developfrom
Yannicked:fix/v1.2-upload
Open

Fix issue with uploading#121
Yannicked wants to merge 1 commit into
iterorganization:developfrom
Yannicked:fix/v1.2-upload

Conversation

@Yannicked

Copy link
Copy Markdown
Collaborator

The IDS list got deserialized wrongly. Also fixes an issue with calculating the checksum of IMAS data in a docker setup

Comment on lines +533 to +543
@field_validator("ids_list", mode="before")
@classmethod
def _coerce_ids_list(cls, v: Any) -> Any:
"""Accept the display-string form of the IDS list, ``"[a, b, c]"``."""
if not isinstance(v, str):
return v
text = v.strip()
if text.startswith("[") and text.endswith("]"):
text = text[1:-1]
return [name.strip() for name in text.split(",") if name.strip()]

@Louwrensth Louwrensth Aug 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong, but this shouldn't be necessary.

Pydantic should have already excellent support for deserializing a string ('[disruption, equilibrium..rofiles, summary, wall]') to list of strings (or other Any objects)

Is it possible that somehow the string got quoted doubly?

@Yannicked Yannicked Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a double-quoting issue. The string doesn't seem to be JSON to begin with.

[a, b, c] is not valid json. ["a", "b", "c"] is

It's built by hand as a display string in database/models/simulation.py:224:

self.set_meta("input_ids", "[{}]".format(", ".join(all_input_idss)))

@Louwrensth Louwrensth Aug 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's fix that anomaly at the source then, no?

Thanks for showing where that string came from, btw!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing at the source would also have my preference, but that would mean that older clients will not work anymore.

(and we'd also have to write migrations for the database, because this string is stored there :(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bummer!

Maybe in a future major release, all the serialization at the source could be replaced by Pydantic's serialization, and then any "serialization by hand" should be forbidden?

@Louwrensth Louwrensth Aug 26, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a double-quoting issue. The string doesn't seem to be JSON to begin with.

[a, b, c] is not valid json. ["a", "b", "c"] is

It's built by hand as a display string in database/models/simulation.py:224:

self.set_meta("input_ids", "[{}]".format(", ".join(all_input_idss)))
[...]
Fixing at the source would also have my preference, but that would mean that older clients will not work anymore.

(and we'd also have to write migrations for the database, because this string is stored there :(

This appears to be a bug in current clients, because the database model expects JSON already:

_metadata = Column(
"metadata",
MutableDict.as_mutable(
postgresql.JSONB(astext_type=sql_types.Text()).with_variant(
JSON(), "sqlite"
)
),

Addressing this would likely obsolete src/simdb/database/models/utils.py in favor of a few of Pydantic's serialization and validation methods.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing at the source would also have my preference, but that would mean that older clients will not work anymore.

(and we'd also have to write migrations for the database, because this string is stored there :(

From #120 older clients are not going to work anymore anyway or am I missing something?
In practice this next release from develop will be most probably 1.0, so a major bump.
Plus we already require database migration with Alembic, so it might be the right time to also fix this serialization in your preferred way now no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants