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

documentation: Database migration step not clear in developer docs #2612

Closed
Ankush-Chander opened this issue Mar 28, 2023 · 3 comments · Fixed by #2613
Closed

documentation: Database migration step not clear in developer docs #2612

Ankush-Chander opened this issue Mar 28, 2023 · 3 comments · Fixed by #2613

Comments

@Ankush-Chander
Copy link
Contributor

Describe the bug
I am following developer setup link and upon running

python -m argilla

I am getting following error:

INFO:     Started server process [3208]
INFO:     Waiting for application startup.
ERROR:    Traceback (most recent call last):
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1965, in _exec_single_context
    cursor, str_statement, effective_parameters, context
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 748, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: no such table: users

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/starlette/routing.py", line 671, in lifespan
    async with self.lifespan_context(app):
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/starlette/routing.py", line 566, in __aenter__
    await self._router.startup()
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/starlette/routing.py", line 648, in startup
    await handler()
  File "/media/disk2/ANKUSH/nlp_repos/argilla/src/argilla/server/server.py", line 231, in log_default_user_warning_if_present
    default_user = accounts.get_user_by_username(db, DEFAULT_USERNAME)
  File "/media/disk2/ANKUSH/nlp_repos/argilla/src/argilla/server/contexts/accounts.py", line 87, in get_user_by_username
    return db.query(User).filter_by(username=username).first()
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 2752, in first
    return self.limit(1)._iter().first()  # type: ignore
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 2858, in _iter
    execution_options={"_sa_orm_load_options": self.load_options},
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2235, in execute
    _add_event=_add_event,
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2130, in _execute_internal
    conn,
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/orm/context.py", line 254, in orm_execute_statement
    statement, params or {}, execution_options=execution_options
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1417, in execute
    execution_options or NO_OPTIONS,
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 487, in _execute_on_connection
    self, distilled_params, execution_options
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1648, in _execute_clauseelement
    cache_hit=cache_hit,
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1843, in _execute_context
    dialect, context, statement, parameters
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1984, in _exec_single_context
    e, str_statement, effective_parameters, cursor, context
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2326, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1965, in _exec_single_context
    cursor, str_statement, effective_parameters, context
  File "/media/disk2/ANKUSH/nlp_repos/argilla_setup/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 748, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: users
[SQL: SELECT users.id AS users_id, users.first_name AS users_first_name, users.last_name AS users_last_name, users.username AS users_username, users.role AS users_role, users.api_key AS users_api_key, users.password_hash AS users_password_hash, users.inserted_at AS users_inserted_at, users.updated_at AS users_updated_at 
FROM users 
WHERE users.username = ?
 LIMIT ? OFFSET ?]
[parameters: ('argilla', 1, 0)]
(Background on this error at: https://sqlalche.me/e/20/e3q8)

ERROR:    Application startup failed. Exiting.

I was able to get past this error by running following command(although I am not sure if this is the right way to setup fresh database):

python3 -m argilla.tasks.database.migrate

To Reproduce
Steps to reproduce the behavior:

  1. Follow instructions mentioned here

Expected behavior
DB setup needs to be added in documentation. Also we can point the developer to Elasticsearch setup in case user hasn"t done it already.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS [e.g. iOS]:
  • Browser [e.g. chrome, safari]:
  • Argilla Version [e.g. 1.0.0]:
  • ElasticSearch Version [e.g. 7.10.2]:
  • Docker Image (optional) [e.g. argilla:v1.0.0]:

Additional context
Add any other context about the problem here.

@jfcalvo
Copy link
Member

jfcalvo commented Mar 28, 2023

@Ankush-Chander thanks for creating the issue. I have created a PR adding the missing step here: #2613

@Ankush-Chander
Copy link
Contributor Author

Ankush-Chander commented Mar 28, 2023

Hi @jfcalvo
Thanks for taking it up swiftly.

I was wondering if we can also add link to elasticsearch setup in the same doc.

So it can be broken into 3 steps:

  1. Database setups
    sqlite and elasticsearch
  2. Server setup (from source)
  3. frontend setup (via bash)

jfcalvo added a commit that referenced this issue Mar 28, 2023
#2613)

# Description

This PR adds a missing step describing the execution of database
migrations for developer documentation.

Closes #2612

**Type of change**

(Please delete options that are not relevant. Remember to title the PR
according to the type of change)

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Refactor (change restructuring the codebase without changing
functionality)
- [ ] Improvement (change adding some improvement to an existing
functionality)
- [x] Documentation update

**Checklist**

- [x] I have merged the original branch into my forked branch
- [x] I added relevant documentation
- [x] follows the style guidelines of this project
- [x] I did a self-review of my code
- [x] I made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] <del>I have added tests that prove my fix is effective or that my
feature works</del> (Not necessary)
- [ ] <del>I have added relevant notes to the CHANGELOG.md file (See
https://keepachangelog.com/)</del> (Not necessary)
@jfcalvo
Copy link
Member

jfcalvo commented Mar 28, 2023

@Ankush-Chander I have tried to apply your feedback on #2613

Please feel free to open a new issue if you think something can be improved. Thanks.

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 a pull request may close this issue.

2 participants