Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Task class with sqlmodel=0.0.7 #147

Closed
tcompa opened this issue Aug 29, 2022 · 4 comments · Fixed by #151 or #166
Closed

Error in Task class with sqlmodel=0.0.7 #147

tcompa opened this issue Aug 29, 2022 · 4 comments · Fixed by #151 or #166
Assignees

Comments

@tcompa
Copy link
Collaborator

tcompa commented Aug 29, 2022

By requiring sqlmodel >=0.0.7, we may use this bugfix - and remove our custom workaround from https://github.com/fractal-analytics-platform/fractal/blob/6b7b3e08875729c32f930a478d545c5ddb382142/fractal/server/app/models/security.py#L22-L36

Version 0.0.7 should be available as of today. To be tested.

@tcompa tcompa changed the title Ask for sqlmodel 0.0.7 Require sqlmodel 0.0.7 Aug 29, 2022
@tcompa tcompa changed the title Require sqlmodel 0.0.7 Require sqlmodel >=0.0.7 Aug 29, 2022
@tcompa tcompa changed the title Require sqlmodel >=0.0.7 Require sqlmodel >=0.0.7 Aug 29, 2022
@tcompa
Copy link
Collaborator Author

tcompa commented Aug 30, 2022

Updating sqlmodel requires adapting to this new PR: Raise an exception when using a Pydantic field type with no matching SQLAlchemy type.

More in detail, right now (after installing sqlmodel=0.0.7), we have that

poetry run python fractal/server/app/models/task.py

fails with

Traceback (most recent call last):
  File "fractal/server/app/models/task.py", line 103, in <module>
    class Task(TaskBase, table=True):  # type: ignore
  File "/home/tommaso/miniconda3/envs/fractal/lib/python3.8/site-packages/sqlmodel/main.py", line 293, in __new__
    col = get_column_from_field(v)
  File "/home/tommaso/miniconda3/envs/fractal/lib/python3.8/site-packages/sqlmodel/main.py", line 421, in get_column_from_field
    sa_type = get_sqlachemy_type(field)
  File "/home/tommaso/miniconda3/envs/fractal/lib/python3.8/site-packages/sqlmodel/main.py", line 414, in get_sqlachemy_type
    raise ValueError(f"The field {field.name} has no matching SQLAlchemy type")
ValueError: The field subtask_list has no matching SQLAlchemy type

@tcompa tcompa changed the title Require sqlmodel >=0.0.7 Error in Task class with sqlmodel=0.0.7 Aug 30, 2022
@jacopo-exact
Copy link
Contributor

looks to me like a bug from upstream. will investigate further.

@jacopo-exact
Copy link
Contributor

it is an edge case: we need to make sure that base models do not contain mapper members (class members that only exist because of some relationship and get filled up by the ORM but do not exist in the db schema).

I already have a mostly working patch, that fails a test because of how the test is written, rather than because of this issue.

@tcompa
Copy link
Collaborator Author

tcompa commented Aug 31, 2022

Great.
Feel free to include it in PR #151

@jacopo-exact jacopo-exact self-assigned this Aug 31, 2022
@tcompa tcompa linked a pull request Sep 1, 2022 that will close this issue
tcompa pushed a commit that referenced this issue Sep 1, 2022
since Task (ORM mapped) inherits from TaskBase and `subtask_list` is of
a type not mapped (i.e., a relationship) an exception is raised in
`sqlmodel>=0.0.7`.

close #147
tcompa added a commit that referenced this issue Sep 1, 2022
…d_uuid

Fix badly-formed UUID error by increasing sqlmodel version (closes #147)
@tcompa tcompa closed this as completed in c1cc703 Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment