langflow-ai / langflow

⛓️ Langflow is a dynamic graph where each node is an executable unit. Its modular and interactive design fosters rapid experimentation and prototyping, pushing hard on the limits of creativity.
http://www.langflow.org
MIT License
17.87k stars 2.68k forks source link

Setup: Pre-release version of Langflow fails to start #1783

Closed Samk13 closed 2 weeks ago

Samk13 commented 3 weeks ago

Describe the bug The pre-release version of Langflow does not start after installation using the pip install langflow --pre --force-reinstall. The stable version works without issues.

Browser and Version

To Reproduce Steps to reproduce the behavior:

  1. install using pip install langflow --pre --force-reinstall
  2. Attempt to run the application with langflow run
  3. See error
  4. Run langflow migration --fix
  5. Attempt to run the application again
  6. See same error

Screenshots langflow_pre

Additional context The error does not occur when installing and running the stable version using pip install langflow -U.

However, here are the logs when running langflow migration --test

2024-04-27 21:16:41.897 | ERROR    | langflow.services.database.service:run_migrations:171 - AutogenerateDiffsDetected: New upgrade operations detected: [[('modify_type', None, 'apikey', 'created_at', {'existing_nullable': True, 'existing_server_default': DefaultClause(<sqlalchemy.sql.elements.TextClause object at 0x7f3dd30e7d50>, for_update=False), 'existing_comment': None}, TIMESTAMP(), DateTime(timezone=True)), ('modify_nullable', None, 'apikey', 'created_at', {'existing_type': TIMESTAMP(), 'existing_server_default': DefaultClause(<sqlalchemy.sql.elements.TextClause object at 0x7f3dd30e7d50>, for_update=False), 'existing_comment': None}, True, False)]]
2024-04-27 21:16:41.897 | ERROR    | langflow.services.database.utils:initialize_database:51 - Something went wrong running migrations. Please, run `langflow migration --fix`
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/user/.pyenv/versions/3.11.7/envs/langflow-test-2/lib/python3.11/site-packages/langflow/s │
│ ervices/database/service.py:169 in run_migrations                                                │
│                                                                                                  │
│   166 │   │                                                                                      │
│   167 │   │   try:                                                                               │
│   168 │   │   │   buffer.write(f"{datetime.now().isoformat()}: Checking migrations\n")           │
│ ❱ 169 │   │   │   command.check(alembic_cfg)                                                     │
│   170 │   │   except util.exc.AutogenerateDiffsDetected as exc:                                  │
│   171 │   │   │   logger.error(f"AutogenerateDiffsDetected: {exc}")                              │
│   172 │   │   │   if not fix:                                                                    │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │               alembic_cfg = <alembic.config.Config object at 0x7f3dd3624d50>                 │ │
│ │                    buffer = <_io.TextIOWrapper                                               │ │
│ │                             name='/home/user/.pyenv/versions/3.11.7/envs/langflow-test-2/… │ │
│ │                             mode='w' encoding='UTF-8'>                                       │ │
│ │                       fix = False                                                            │ │
│ │                      self = <langflow.services.database.service.DatabaseService object at    │ │
│ │                             0x7f3dd3541090>                                                  │ │
│ │                   session = <sqlmodel.orm.session.Session object at 0x7f3dd37ba150>          │ │
│ │ should_initialize_alembic = False                                                            │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /home/user/.pyenv/versions/3.11.7/envs/langflow-test-2/lib/python3.11/site-packages/alembic/co │
│ mmand.py:300 in check                                                                            │
│                                                                                                  │
│   297 │   │   diffs.extend(upgrade_ops.as_diffs())                                               │
│   298 │                                                                                          │
│   299 │   if diffs:                                                                              │
│ ❱ 300 │   │   raise util.AutogenerateDiffsDetected(                                              │
│   301 │   │   │   f"New upgrade operations detected: {diffs}"                                    │
│   302 │   │   )                                                                                  │
│   303 │   else:                                                                                  │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │        command_args = {                                                                      │ │
│ │                       │   'message': None,                                                   │ │
│ │                       │   'autogenerate': True,                                              │ │
│ │                       │   'sql': False,                                                      │ │
│ │                       │   'head': 'head',                                                    │ │
│ │                       │   'splice': False,                                                   │ │
│ │                       │   'branch_label': None,                                              │ │
│ │                       │   'version_path': None,                                              │ │
│ │                       │   'rev_id': None,                                                    │ │
│ │                       │   'depends_on': None                                                 │ │
│ │                       }                                                                      │ │
│ │              config = <alembic.config.Config object at 0x7f3dd3624d50>                       │ │
│ │               diffs = [                                                                      │ │
│ │                       │   [                                                                  │ │
│ │                       │   │   (                                                              │ │
│ │                       │   │   │   'modify_type',                                             │ │
│ │                       │   │   │   None,                                                      │ │
│ │                       │   │   │   'apikey',                                                  │ │
│ │                       │   │   │   'created_at',                                              │ │
│ │                       │   │   │   {                                                          │ │
│ │                       │   │   │   │   'existing_nullable': True,                             │ │
│ │                       │   │   │   │   'existing_server_default':                             │ │
│ │                       DefaultClause(<sqlalchemy.sql.elements.TextClause object at            │ │
│ │                       0x7f3dd30e7d50>, for_update=False),                                    │ │
│ │                       │   │   │   │   'existing_comment': None                               │ │
│ │                       │   │   │   },                                                         │ │
│ │                       │   │   │   TIMESTAMP(),                                               │ │
│ │                       │   │   │   DateTime(timezone=True)                                    │ │
│ │                       │   │   ),                                                             │ │
│ │                       │   │   (                                                              │ │
│ │                       │   │   │   'modify_nullable',                                         │ │
│ │                       │   │   │   None,                                                      │ │
│ │                       │   │   │   'apikey',                                                  │ │
│ │                       │   │   │   'created_at',                                              │ │
│ │                       │   │   │   {                                                          │ │
│ │                       │   │   │   │   'existing_type': TIMESTAMP(),                          │ │
│ │                       │   │   │   │   'existing_server_default':                             │ │
│ │                       DefaultClause(<sqlalchemy.sql.elements.TextClause object at            │ │
│ │                       0x7f3dd30e7d50>, for_update=False),                                    │ │
│ │                       │   │   │   │   'existing_comment': None                               │ │
│ │                       │   │   │   },                                                         │ │
│ │                       │   │   │   True,                                                      │ │
│ │                       │   │   │   False                                                      │ │
│ │                       │   │   )                                                              │ │
│ │                       │   ]                                                                  │ │
│ │                       ]                                                                      │ │
│ │    migration_script = <alembic.operations.ops.MigrationScript object at 0x7f3dd33f2490>      │ │
│ │ retrieve_migrations = <function check.<locals>.retrieve_migrations at 0x7f3dd33bccc0>        │ │
│ │    revision_context = <alembic.autogenerate.api.RevisionContext object at 0x7f3dd334dcd0>    │ │
│ │    script_directory = <alembic.script.base.ScriptDirectory object at 0x7f3dd3332750>         │ │
│ │         upgrade_ops = <alembic.operations.ops.UpgradeOps object at 0x7f3dd334db10>           │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AutogenerateDiffsDetected: New upgrade operations detected: [[('modify_type', None, 'apikey', 'created_at', {'existing_nullable': True, 'existing_server_default': DefaultClause(<sqlalchemy.sql.elements.TextClause object at 0x7f3dd30e7d50>,
for_update=False), 'existing_comment': None}, TIMESTAMP(), DateTime(timezone=True)), ('modify_nullable', None, 'apikey', 'created_at', {'existing_type': TIMESTAMP(), 'existing_server_default': DefaultClause(<sqlalchemy.sql.elements.TextClause object
at 0x7f3dd30e7d50>, for_update=False), 'existing_comment': None}, True, False)]]

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

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/user/.pyenv/versions/3.11.7/envs/langflow-test-2/lib/python3.11/site-packages/langflow/_ │
│ _main__.py:462 in migration                                                                      │
│                                                                                                  │
│   459 │   │   ):                                                                                 │
│   460 │   │   │   raise typer.Abort()                                                            │
│   461 │                                                                                          │
│ ❱ 462 │   initialize_services(fix_migration=fix)                                                 │
│   463 │   db_service = get_db_service()                                                          │
│   464 │   if not test:                                                                           │
│   465 │   │   db_service.run_migrations()                                                        │
│                                                                                                  │
│ ╭─── locals ───╮                                                                                 │
│ │  fix = False │                                                                                 │
│ │ test = True  │                                                                                 │
│ ╰──────────────╯                                                                                 │
│                                                                                                  │
│ /home/user/.pyenv/versions/3.11.7/envs/langflow-test-2/lib/python3.11/site-packages/langflow/s │
│ ervices/utils.py:166 in initialize_services                                                      │
│                                                                                                  │
│   163 │   try:                                                                                   │
│   164 │   │   initialize_database(fix_migration=fix_migration)                                   │
│   165 │   except Exception as exc:                                                               │
│ ❱ 166 │   │   raise exc                                                                          │
│   167 │   setup_superuser(get_service(ServiceType.SETTINGS_SERVICE), next(get_session()))        │
│   168 │   try:                                                                                   │
│   169 │   │   get_db_service().migrate_flows_if_auto_login()                                     │
│                                                                                                  │
│ ╭──────── locals ─────────╮                                                                      │
│ │   fix_migration = False │                                                                      │
│ │ socketio_server = None  │                                                                      │
│ ╰─────────────────────────╯                                                                      │
│                                                                                                  │
│ /home/user/.pyenv/versions/3.11.7/envs/langflow-test-2/lib/python3.11/site-packages/langflow/s │
│ ervices/utils.py:164 in initialize_services                                                      │
│                                                                                                  │
│   161 │   get_service(ServiceType.CACHE_SERVICE, default=CacheServiceFactory())                  │
│   162 │   # Setup the superuser                                                                  │
│   163 │   try:                                                                                   │
│ ❱ 164 │   │   initialize_database(fix_migration=fix_migration)                                   │
│   165 │   except Exception as exc:                                                               │
│   166 │   │   raise exc                                                                          │
│   167 │   setup_superuser(get_service(ServiceType.SETTINGS_SERVICE), next(get_session()))        │
│                                                                                                  │
│ ╭──────── locals ─────────╮                                                                      │
│ │   fix_migration = False │                                                                      │
│ │ socketio_server = None  │                                                                      │
│ ╰─────────────────────────╯                                                                      │
│                                                                                                  │
│ /home/user/.pyenv/versions/3.11.7/envs/langflow-test-2/lib/python3.11/site-packages/langflow/s │
│ ervices/database/utils.py:52 in initialize_database                                              │
│                                                                                                  │
│   49 │   │   # we can ignore it                                                                  │
│   50 │   │   if "already exists" not in str(exc):                                                │
│   51 │   │   │   logger.error(exc)                                                               │
│ ❱ 52 │   │   raise exc                                                                           │
│   53 │   logger.debug("Database initialized")                                                    │
│   54                                                                                             │
│   55                                                                                             │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ database_service = <langflow.services.database.service.DatabaseService object at             │ │
│ │                    0x7f3dd3541090>                                                           │ │
│ │    fix_migration = False                                                                     │ │
│ │   get_db_service = <function get_db_service at 0x7f3dfeef1260>                               │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /home/user/.pyenv/versions/3.11.7/envs/langflow-test-2/lib/python3.11/site-packages/langflow/s │
│ ervices/database/utils.py:32 in initialize_database                                              │
│                                                                                                  │
│   29 │   │   logger.error(f"Error checking schema health: {exc}")                                │
│   30 │   │   raise RuntimeError("Error checking schema health") from exc                         │
│   31 │   try:                                                                                    │
│ ❱ 32 │   │   database_service.run_migrations(fix=fix_migration)                                  │
│   33 │   except CommandError as exc:                                                             │
│   34 │   │   # if "overlaps with other requested revisions" or "Can't locate revision identif    │
│   35 │   │   # are not in the exception, we can't handle it                                      │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ database_service = <langflow.services.database.service.DatabaseService object at             │ │
│ │                    0x7f3dd3541090>                                                           │ │
│ │    fix_migration = False                                                                     │ │
│ │   get_db_service = <function get_db_service at 0x7f3dfeef1260>                               │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /home/user/.pyenv/versions/3.11.7/envs/langflow-test-2/lib/python3.11/site-packages/langflow/s │
│ ervices/database/service.py:173 in run_migrations                                                │
│                                                                                                  │
│   170 │   │   except util.exc.AutogenerateDiffsDetected as exc:                                  │
│   171 │   │   │   logger.error(f"AutogenerateDiffsDetected: {exc}")                              │
│   172 │   │   │   if not fix:                                                                    │
│ ❱ 173 │   │   │   │   raise RuntimeError(                                                        │
│   174 │   │   │   │   │   "Something went wrong running migrations. Please, run `langflow migr   │
│   175 │   │   │   │   ) from exc                                                                 │
│   176                                                                                            │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │               alembic_cfg = <alembic.config.Config object at 0x7f3dd3624d50>                 │ │
│ │                    buffer = <_io.TextIOWrapper                                               │ │
│ │                             name='/home/user/.pyenv/versions/3.11.7/envs/langflow-test-2/… │ │
│ │                             mode='w' encoding='UTF-8'>                                       │ │
│ │                       fix = False                                                            │ │
│ │                      self = <langflow.services.database.service.DatabaseService object at    │ │
│ │                             0x7f3dd3541090>                                                  │ │
│ │                   session = <sqlmodel.orm.session.Session object at 0x7f3dd37ba150>          │ │
│ │ should_initialize_alembic = False                                                            │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
RuntimeError: Something went wrong running migrations. Please, run `langflow migration --fix`
Samk13 commented 2 weeks ago

The issue continues to occur with version 1.0.0a27.

luizhsalazar commented 2 weeks ago

Same issue here, even running version 1.0.0a27, as mentioned by @Samk13 .

Samk13 commented 2 weeks ago

The issue persists in version 1.0.0a28 If I'm overlooking something obvious, I would appreciate any pointers!

sondonghup commented 2 weeks ago

i had the same issue @Samk13 @luizhsalazar i solved with langflow.db renaming

  1. find your langflow-pre.db in .cache folder (i was in home/user/.cache/langflow/langflow-pre.db)
  2. rename langflow-pre.db as you want (like langflow-pre1.db or langflow-pre2.db ... else)
  3. and run it with langflow run

I did it in version v1.0.0.a28

Samk13 commented 2 weeks ago

Thanx @sondonghup Resolved by clearing the LangFlow cache: rm -rf home/user/.cache/langflow/.