You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@hamilton.apache.org by "MitchellAcoustics (via GitHub)" <gi...@apache.org> on 2026/06/23 11:01:57 UTC

[I] Hamilton local ui fails with ImportError [hamilton]

MitchellAcoustics opened a new issue, #1649:
URL: https://github.com/apache/hamilton/issues/1649

   # Current behavior
   `hamilton ui` fails with `ImportError: cannot import name 'API_KEY' from 'hamilton.telemetry'`
   
   ## Stack Traces
   ```bash
   ╭────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────────────────────────────────────────╮
   │ /home/amitchell/trials/hamilton-data-pipelines/.venv/lib/python3.12/site-packages/hamilton/cli/__main__.py:316 in ui                                                                   │
   │                                                                                                                                                                                        │
   │   313 │   │   )                                                                                                                                                                        │
   │   314 │   │   raise typer.Exit(code=1) from e                                                                                                                                          │
   │   315 │                                                                                                                                                                                │
   │ ❱ 316 │   ctx.invoke(                                                                                                                                                                  │
   │   317 │   │   commands.run,                                                                                                                                                            │
   │   318 │   │   port=port,                                                                                                                                                               │
   │   319 │   │   base_dir=base_dir,                                                                                                                                                       │
   │                                                                                                                                                                                        │
   │ /home/amitchell/trials/hamilton-data-pipelines/.venv/lib/python3.12/site-packages/typer/_click/core.py:489 in invoke                                                                   │
   │                                                                                                                                                                                        │
   │ /home/amitchell/trials/hamilton-data-pipelines/.venv/lib/python3.12/site-packages/hamilton_ui/commands.py:131 in run                                                                   │
   │                                                                                                                                                                                        │
   │   128 │   │   with set_env_variables(env):                                                                                                                                             │
   │   129 │   │   │   settings_file_param = f"--settings={settings_file.value}"                                                                                                            │
   │   130 │   │   │   if not no_migration:                                                                                                                                                 │
   │ ❱ 131 │   │   │   │   execute_from_command_line(["manage.py", "migrate", settings_file_param])                                                                                         │
   │   132 │   │   │   execute_from_command_line(                                                                                                                                           │
   │   133 │   │   │   │   # Why insecure? Because we're running locally using django's server which                                                                                        │
   │   134 │   │   │   │   # is not specifically meant for production. That said, we'll be fixing this up shortly,                                                                          │
   │                                                                                                                                                                                        │
   │ /home/amitchell/trials/hamilton-data-pipelines/.venv/lib/python3.12/site-packages/django/core/management/__init__.py:443 in execute_from_command_line                                  │
   │                                                                                                                                                                                        │
   │   440 def execute_from_command_line(argv=None):                                                                                                                                        │
   │   441 │   """Run a ManagementUtility."""                                                                                                                                               │
   │   442 │   utility = ManagementUtility(argv)                                                                                                                                            │
   │ ❱ 443 │   utility.execute()                                                                                                                                                            │
   │   444                                                                                                                                                                                  │
   │                                                                                                                                                                                        │
   │ /home/amitchell/trials/hamilton-data-pipelines/.venv/lib/python3.12/site-packages/django/core/management/__init__.py:417 in execute                                                    │
   │                                                                                                                                                                                        │
   │   414 │   │   │                                                                                                                                                                        │
   │   415 │   │   │   # In all other cases, django.setup() is required to succeed.                                                                                                         │
   │   416 │   │   │   else:                                                                                                                                                                │
   │ ❱ 417 │   │   │   │   django.setup()                                                                                                                                                   │
   │   418 │   │                                                                                                                                                                            │
   │   419 │   │   self.autocomplete()                                                                                                                                                      │
   │   420                                                                                                                                                                                  │
   │                                                                                                                                                                                        │
   │ /home/amitchell/trials/hamilton-data-pipelines/.venv/lib/python3.12/site-packages/django/__init__.py:24 in setup                                                                       │
   │                                                                                                                                                                                        │
   │   21 │   │   set_script_prefix(                                                                                                                                                        │
   │   22 │   │   │   "/" if settings.FORCE_SCRIPT_NAME is None else settings.FORCE_SCRIPT_NAME                                                                                             │
   │   23 │   │   )                                                                                                                                                                         │
   │ ❱ 24 │   apps.populate(settings.INSTALLED_APPS)                                                                                                                                        │
   │   25                                                                                                                                                                                   │
   │                                                                                                                                                                                        │
   │ /home/amitchell/trials/hamilton-data-pipelines/.venv/lib/python3.12/site-packages/django/apps/registry.py:91 in populate                                                               │
   │                                                                                                                                                                                        │
   │    88 │   │   │   │   if isinstance(entry, AppConfig):                                                                                                                                 │
   │    89 │   │   │   │   │   app_config = entry                                                                                                                                           │
   │    90 │   │   │   │   else:                                                                                                                                                            │
   │ ❱  91 │   │   │   │   │   app_config = AppConfig.create(entry)                                                                                                                         │
   │    92 │   │   │   │   if app_config.label in self.app_configs:                                                                                                                         │
   │    93 │   │   │   │   │   raise ImproperlyConfigured(                                                                                                                                  │
   │    94 │   │   │   │   │   │   "Application labels aren't unique, "                                                                                                                     │
   │                                                                                                                                                                                        │
   │ /home/amitchell/trials/hamilton-data-pipelines/.venv/lib/python3.12/site-packages/django/apps/config.py:178 in create                                                                  │
   │                                                                                                                                                                                        │
   │   175 │   │   │   │   # message for typos in INSTALLED_APPS.                                                                                                                           │
   │   176 │   │   │   │   # This may raise ImportError, which is the best exception                                                                                                        │
   │   177 │   │   │   │   # possible if the module at mod_path cannot be imported.                                                                                                         │
   │ ❱ 178 │   │   │   │   mod = import_module(mod_path)                                                                                                                                    │
   │   179 │   │   │   │   candidates = [                                                                                                                                                   │
   │   180 │   │   │   │   │   repr(name)                                                                                                                                                   │
   │   181 │   │   │   │   │   for name, candidate in inspect.getmembers(mod, inspect.isclass)                                                                                              │
   │                                                                                                                                                                                        │
   │ /home/amitchell/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/importlib/__init__.py:90 in import_module                                                       │
   │                                                                                                                                                                                        │
   │    87 │   │   │   if character != '.':                                                                                                                                                 │
   │    88 │   │   │   │   break                                                                                                                                                            │
   │    89 │   │   │   level += 1                                                                                                                                                           │
   │ ❱  90 │   return _bootstrap._gcd_import(name[level:], package, level)                                                                                                                  │
   │    91                                                                                                                                                                                  │
   │    92                                                                                                                                                                                  │
   │    93 _RELOADING = {}                                                                                                                                                                  │
   │ in _gcd_import:1387                                                                                                                                                                    │
   │ in _find_and_load:1360                                                                                                                                                                 │
   │ in _find_and_load_unlocked:1331                                                                                                                                                        │
   │ in _load_unlocked:935                                                                                                                                                                  │
   │ in exec_module:999                                                                                                                                                                     │
   │ in _call_with_frames_removed:488                                                                                                                                                       │
   │                                                                                                                                                                                        │
   │ /home/amitchell/trials/hamilton-data-pipelines/.venv/lib/python3.12/site-packages/hamilton_ui/trackingserver_base/apps.py:8 in <module>                                                │
   │                                                                                                                                                                                        │
   │    5 from django.conf import settings                                                                                                                                                  │
   │    6 from django.db import models                                                                                                                                                      │
   │    7                                                                                                                                                                                   │
   │ ❱  8 from hamilton.telemetry import API_KEY, BASE_PROPERTIES, is_telemetry_enabled, send_event_json                                                                                    │
   │    9                                                                                                                                                                                   │
   │   10                                                                                                                                                                                   │
   │   11 def create_server_event_json(telemetry_key: str) -> dict:                                                                                                                         │
   ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
   ImportError: cannot import name 'API_KEY' from 'hamilton.telemetry'
   ```
   
   ## Screenshots
   (If applicable)
   
   
   ## Steps to replicate behavior
   1. Install hamilton: `uv add "apache-hamilton[ui,sdk]"`
   2. Run `hamilton ui`
   
   (Alternatively reproduced with just: `uvx --from "apache-hamilton[ui,sdk]" hamilton ui`
   
   ## Library & System Information
   python                        3.12.13
   apache-hamilton         1.90.0
   sf-hamilton                  1.90.0
   sf-hamilton-sdk           0.8.0
   sf-hamilton-ui              0.0.17
   django                         6.0.6
   django-extensions       4.1
   django-ninja                 1.6.2
   
   # Expected behavior
   ui launches locally.
   
   # Additional context
   It seems related to commit https://github.com/apache/hamilton/pull/1512 where the telemetry was pulled out.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@hamilton.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Hamilton local ui fails with ImportError [hamilton]

Posted by "ebarkhordar (via GitHub)" <gi...@apache.org>.
ebarkhordar commented on issue #1649:
URL: https://github.com/apache/hamilton/issues/1649#issuecomment-5760335745

   sf-hamilton-ui 0.0.17 imports `API_KEY` at `trackingserver_base/apps.py:8`, and #1512 removed that name from `hamilton.telemetry`. Fixed in ui 0.0.18 (2026-07-14): `hamilton ui` starts clean on a fresh install here.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@hamilton.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Hamilton local ui fails with ImportError [hamilton]

Posted by "skrawcz (via GitHub)" <gi...@apache.org>.
skrawcz commented on issue #1649:
URL: https://github.com/apache/hamilton/issues/1649#issuecomment-5771274282

   Fixed in sf-hamilton-ui 0.0.18. The failing 0.0.17 package imported telemetry symbols removed from Hamilton core; the updated UI package no longer does so. Please reopen if a clean install with UI 0.0.18 or newer still reproduces the failure.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@hamilton.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Hamilton local ui fails with ImportError [hamilton]

Posted by "skrawcz (via GitHub)" <gi...@apache.org>.
skrawcz closed issue #1649: Hamilton local ui fails with ImportError
URL: https://github.com/apache/hamilton/issues/1649


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@hamilton.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org