Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

fix/database issues #55

Merged
merged 5 commits into from
May 22, 2023
Merged

fix/database issues #55

merged 5 commits into from
May 22, 2023

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Apr 8, 2023

some of the new CRUD endpoints have a few bugs

test with backend-client OpenVoiceOS/ovos-backend-client#30

    db = DatabaseApi("666", backend_type=BackendType.PERSONAL)
    print(db.list_devices())
    print(db.delete_device("123"))
    print(db.add_device("123", "testtoken"))
    print(db.list_devices())
    print(db.get_device("123"))
    print(db.list_devices())
    print(db.update_device("123", name="bad device"))
    print(db.get_device("123"))
    print(db.delete_device("123"))
    print(db.list_devices())
``

some of the new CRUD endpoints have a few bugs
@JarbasAl JarbasAl added the bug Something isn't working label Apr 8, 2023
@JarbasAl JarbasAl requested a review from a team April 8, 2023 01:53
JarbasAl added 3 commits April 8, 2023 03:08
some of the new CRUD endpoints have a few bugs
some of the new CRUD endpoints have a few bugs
some of the new CRUD endpoints have a few bugs
@emphasize
Copy link
Member

emphasize commented Apr 8, 2023

Getting back on #51 (comment)

theoretically this is correct, but practically it doesn't pull Flask-MySQLdb (tested in a docker scenario)

WARNING: ovos-local-backend 0.2.0a5 does not provide the extra 'mysql'

EDIT: Got the problem. We have to use extras_require instead of extras_requires here

@emphasize
Copy link
Member

emphasize commented Apr 8, 2023

problems with a keyword (also meta -> metadata_json)

class SkillSettings(db.Model):
remote_id = db.Column(db.String(255),
primary_key=True) # depends on Device.isolated_skills, @{uuid}|{skill_id} or {skill_id}
display_name = db.Column(db.String(255)) # for friendly UI, default to skill_id
settings = db.Column(NestedMutableJson, nullable=False, default="{}") # actual skill settings file
meta = db.Column(NestedMutableJson, nullable=False, default="{}") # how to display user facing settings editor

[2023-04-08 14:42:19,999] ERROR in app: Exception on /v1/device/b1c9a688-c92c-495d-bea3-699a15f15225/skill [PUT]
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 2528, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/usr/local/lib/python3.10/dist-packages/ovos_local_backend/backend/decorators.py", line 56, in decorated
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/ovos_local_backend/backend/device.py", line 57, in skill_settings
    s = SkillSettings.deserialize(flask.request.json)
  File "/usr/local/lib/python3.10/dist-packages/ovos_local_backend/database.py", line 394, in deserialize
    return update_skill_settings(remote_id,
  File "/usr/local/lib/python3.10/dist-packages/ovos_local_backend/database.py", line 746, in update_skill_settings
    settings = add_skill_settings(remote_id=remote_id,
  File "/usr/local/lib/python3.10/dist-packages/ovos_local_backend/database.py", line 700, in add_skill_settings
    entry = SkillSettings(remote_id=remote_id,
  File "<string>", line 4, in __init__
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/orm/state.py", line 575, in _initialize_instance
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/util/langhelpers.py", line 147, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/orm/state.py", line 573, in _initialize_instance
    manager.original_init(*mixed[1:], **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/orm/decl_base.py", line 2139, in _declarative_constructor
    raise TypeError(
TypeError: 'settings_json' is an invalid keyword argument for SkillSettings

BTW the default has to be a dict, not a str

some of the new CRUD endpoints have a few bugs
@JarbasAl
Copy link
Member Author

JarbasAl commented Apr 9, 2023

@|ovos-skills-info.openvoiceos

besides above issue it writes a remote_id entry (SkillSettings) without uuid EDIT: _(seen that this is a result of isolated_skills = False, but looking at _

if device.isolated_skills:
remote_id = f"@{uuid}|{skill_id}"
else:
remote_id = skill_id

_ this shouldn't have @|)_

(endpoint /v1/device/uuid/skill (device.py) - SkillSettingsApi().upload_skill_settings())

i think core might be sending it that way already as it was expected by selene....

@emphasize
Copy link
Member

Yeah, saw that. That's why i deleted the comment

@JarbasAl JarbasAl merged commit 9292276 into dev May 22, 2023
@JarbasAl JarbasAl deleted the fix/more_sql_bugs branch May 22, 2023 23:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants