Skip to content

Hamilton UI error at startup due to django-ninja ConfigError #1457

@jhrinv

Description

@jhrinv

A fresh install and running of hamilton ui fails with ninja complaining like this:

ConfigError: The use of `Config` class is removed for ModelSchema, use 'Meta' instead

Thus, I cannot start the Hamilton UI at all to try it out on my machine. I also add the information from my pyproject.toml because maybe it is a dependency issue. From the references below, it looks as if this error is related to django-ninja, whereas I do not understand the details. Who can help as to why this happens?

Current behavior

I perform these two steps:

$ uv add sf-hamilton[ui,sdk]
$ hamilton ui

with the last one failing with the stack trace below.

Relevant Issues With Ninja

Stack Traces

$ uv run hamilton ui
╭────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────────╮
│ ...\.venv\Lib\site-packages\hamilton\cli\__main__.py:324 in ui                                                                                           │
│                                                                                                                                                                                                       │
│   321 │   │   )                                                                                                                                                                                       │
│   322 │   │   raise typer.Exit(code=1) from e                                                                                                                                                         │
│   323 │                                                                                                                                                                                               │
│ ❱ 324 │   ctx.invoke(                                                                                                                                                                                 │
│   325 │   │   commands.run,                                                                                                                                                                           │
│   326 │   │   port=port,                                                                                                                                                                              │
│   327 │   │   base_dir=base_dir,                                                                                                                                                                      │
│                                                                                                                                                                                                       │
│ ╭───────────────────────────────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────────────────────────────╮                                  │
│ │      base_dir = 'C:\\Users\\jhr.INVERSO\\.hamilton\\db'                                                                                                          │                                  │
│ │      commands = <module 'hamilton_ui.commands' from 'C:\\Users\\jhr.INVERSO\\src\\bdag-schaden-doc-ingest\\.venv\\Lib\\site-packages\\hamilton_ui\\commands.py'> │                                  │
│ │   config_file = None                                                                                                                                             │                                  │
│ │           ctx = <click.core.Context object at 0x000002126A4EFD90>                                                                                                │                                  │
│ │  no_migration = False                                                                                                                                            │                                  │
│ │       no_open = False                                                                                                                                            │                                  │
│ │          port = 8241                                                                                                                                             │                                  │
│ │ settings_file = 'mini'                                                                                                                                           │                                  │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                  │
│                                                                                                                                                                                                       │
│ ...\.venv\Lib\site-packages\click\core.py:824 in invoke                                                                                                  │
│                                                                                                                                                                                                       │
│ ...\.venv\Lib\site-packages\hamilton_ui\commands.py:131 in run                                                                                           │
│                                                                                                                                                                                                       │
│   128 │   │   with set_env_variables(env):                                                     ╭─────────────────────────────────────── locals ───────────────────────────────────────╮               │
│   129 │   │   │   settings_file_param = f"--settings={settings_file.value}"                    │            base_dir = 'C:\\Users\\jhr.INVERSO\\.hamilton\\db'                        │               │
│   130 │   │   │   if not no_migration:                                                         │         config_file = None                                                           │               │
│ ❱ 131 │   │   │   │   execute_from_command_line(["manage.py", "migrate", settings_file_param]) │                 env = {'HAMILTON_BASE_DIR': 'C:\\Users\\jhr.INVERSO\\.hamilton\\db'} │               │
│   132 │   │   │   execute_from_command_line(                                                   │        no_migration = False                                                          │               │
│   133 │   │   │   │   # Why insecure? Because we're running locally using django's server whic │             no_open = False                                                          │               │
│   134 │   │   │   │   # is not specifically meant for production. That said, we'll be fixing t │            open_url = 'http://localhost:8241'                                        │               │
│                                                                                                │                port = 8241                                                           │               │
│                                                                                                │       settings_file = <SettingsFile.mini: 'server.settings_mini'>                    │               │
│                                                                                                │ settings_file_param = '--settings=server.settings_mini'                              │               │
│                                                                                                │              thread = <Thread(Thread-2 (_open_when_ready), started daemon 14616)>    │               │
│                                                                                                ╰──────────────────────────────────────────────────────────────────────────────────────╯               │
│                                                                                                                                                                                                       │
│ ...\.venv\Lib\site-packages\django\core\management\__init__.py:443 in execute_from_command_line                                                          │
│                                                                                                                                                                                                       │
│   440 def execute_from_command_line(argv=None):                                                ╭───────────────────────────────────── locals ──────────────────────────────────────╮                  │
│   441 │   """Run a ManagementUtility."""                                                       │    argv = ['manage.py', 'migrate', '--settings=server.settings_mini']             │                  │
│   442 │   utility = ManagementUtility(argv)                                                    │ utility = <django.core.management.ManagementUtility object at 0x000002126AC2D2B0> │                  │
│ ❱ 443 │   utility.execute()                                                                    ╰───────────────────────────────────────────────────────────────────────────────────╯                  │
│   444                                                                                                                                                                                                 │
│                                                                                                                                                                                                       │
│ ...\.venv\Lib\site-packages\django\core\management\__init__.py:437 in execute                                                                            │
│                                                                                                                                                                                                       │
│   434 │   │   elif self.argv[1:] in (["--help"], ["-h"]):                                                                                                                                             │
│   435 │   │   │   sys.stdout.write(self.main_help_text() + "\n")                                                                                                                                      │
│   436 │   │   else:                                                                                                                                                                                   │
│ ❱ 437 │   │   │   self.fetch_command(subcommand).run_from_argv(self.argv)                                                                                                                             │
│   438                                                                                                                                                                                                 │
│   439                                                                                                                                                                                                 │
│   440 def execute_from_command_line(argv=None):                                                                                                                                                       │
│                                                                                                                                                                                                       │
│ ╭───────────────────────────────────────────────────────────────────────────────────────────── locals ──────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │       args = []                                                                                                                                                                                   │ │
│ │    options = Namespace(settings='server.settings_mini', pythonpath=None, args=[])                                                                                                                 │ │
│ │     parser = CommandParser(prog='manage.py', usage='%(prog)s subcommand [options] [args]', description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error',          │ │
│ │              add_help=False)                                                                                                                                                                      │ │
│ │       self = <django.core.management.ManagementUtility object at 0x000002126AC2D2B0>                                                                                                              │ │
│ │ subcommand = 'migrate'                                                                                                                                                                            │ │
│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                                                                                                                       │
│ ...\.venv\Lib\site-packages\django\core\management\base.py:420 in run_from_argv                                                                          │
│                                                                                                                                                                                                       │
│   417 │   │   args = cmd_options.pop("args", ())                                                                                                                                                      │
│   418 │   │   handle_default_options(options)                                                                                                                                                         │
│   419 │   │   try:                                                                                                                                                                                    │
│ ❱ 420 │   │   │   self.execute(*args, **cmd_options)                                                                                                                                                  │
│   421 │   │   except CommandError as e:                                                                                                                                                               │
│   422 │   │   │   if options.traceback:                                                                                                                                                               │
│   423 │   │   │   │   raise                                                                                                                                                                           │
│                                                                                                                                                                                                       │
│ ╭───────────────────────────────────────────────────────────────────────────────────────────── locals ──────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │        args = ()                                                                                                                                                                                  │ │
│ │        argv = ['manage.py', 'migrate', '--settings=server.settings_mini']                                                                                                                         │ │
│ │ cmd_options = {                                                                                                                                                                                   │ │
│ │               │   'verbosity': 1,                                                                                                                                                                 │ │
│ │               │   'settings': 'server.settings_mini',                                                                                                                                             │ │
│ │               │   'pythonpath': None,                                                                                                                                                             │ │
│ │               │   'traceback': False,                                                                                                                                                             │ │
│ │               │   'no_color': False,                                                                                                                                                              │ │
│ │               │   'force_color': False,                                                                                                                                                           │ │
│ │               │   'skip_checks': False,                                                                                                                                                           │ │
│ │               │   'app_label': None,                                                                                                                                                              │ │
│ │               │   'migration_name': None,                                                                                                                                                         │ │
│ │               │   'interactive': True,                                                                                                                                                            │ │
│ │               │   ... +7                                                                                                                                                                          │ │
│ │               }                                                                                                                                                                                   │ │
│ │     options = Namespace(verbosity=1, settings='server.settings_mini', pythonpath=None, traceback=False, no_color=False, force_color=False, skip_checks=False, app_label=None,                     │ │
│ │               migration_name=None, interactive=True, database='default', fake=False, fake_initial=False, plan=False, run_syncdb=False, check_unapplied=False, prune=False)                        │ │
│ │      parser = CommandParser(prog='manage.py migrate', usage=None, description='Updates database schema. Manages both apps with migrations and those without.', formatter_class=<class             │ │
│ │               'django.core.management.base.DjangoHelpFormatter'>, conflict_handler='error', add_help=True)                                                                                        │ │
│ │        self = <django.core.management.commands.migrate.Command object at 0x000002126C7F78C0>                                                                                                      │ │
│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │


...

│ ...\.venv\Lib\site-packages\ninja\orm\metaclass.py:23 in from_schema_class                                                                               │
│                                                                                                                                                                                                       │
│    20 │   @staticmethod                                                                                                                                                                               │
│    21 │   def from_schema_class(name: str, namespace: dict) -> "MetaConf":                                                                                                                            │
│    22 │   │   if "Config" in namespace:                                                                                                                                                               │
│ ❱  23 │   │   │   raise ConfigError(  # pragma: no cover                                                                                                                                              │
│    24 │   │   │   │   "The use of `Config` class is removed for ModelSchema, use 'Meta' instea                                                                                                        │
│    25 │   │   │   )                                                                                                                                                                                   │
│    26 │   │   if "Meta" in namespace:                                                                                                                                                                 │
│                                                                                                                                                                                                       │
│ ╭────────────────────────────────────────────────────────────────────────────────── locals ──────────────────────────────────────────────────────────────────────────────────╮                        │
│ │      name = 'UserOut'                                                                                                                                                      │                        │
│ │ namespace = {                                                                                                                                                              │                        │
│ │             │   '__module__': 'trackingserver_auth.schema',                                                                                                                │                        │
│ │             │   '__qualname__': 'UserOut',                                                                                                                                 │                        │
│ │             │   'Config': <class 'trackingserver_auth.schema.UserOut.Config'>,                                                                                             │                        │
│ │             │   '__static_attributes__': (),                                                                                                                               │                        │
│ │             │   'model_config': {                                                                                                                                          │                        │
│ │             │   │   'from_attributes': True,                                                                                                                               │                        │
│ │             │   │   'model': <class 'trackingserver_auth.models.User'>,                                                                                                    │                        │
│ │             │   │   'model_fields': ['id', 'email', 'first_name', 'last_name']                                                                                             │                        │
│ │             │   },                                                                                                                                                         │                        │
│ │             │   '__class_vars__': set(),                                                                                                                                   │                        │
│ │             │   '__private_attributes__': {}                                                                                                                               │                        │
│ │             }                                                                                                                                                              │                        │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                        │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
ConfigError: The use of `Config` class is removed for ModelSchema, use 'Meta' instead

Steps to replicate behavior

$ uv init
$ uv add sf-hamilton[ui,sdk]
$ hamilton ui

Library & System Information

  • Python 3.13.7
  • Windows 11

pyproject.toml:

[project]
requires-python = ">=3.13"
dependencies = [
    "langchain-text-splitters>=0.2.0",
    "llvmlite>=0.46.0",
    "markitdown[all]>=0.1.2",
    "pikepdf==10.2.0",
    "polars>=1.31.0",
    "pyarrow==18.0.0",
    "pypdf>=6.6.2",
    "pytest>=8.3.5",
    "python-dotenv>=1.0.0",
    "sf-hamilton[sdk,ui]>=1.89.0",
    "shap>=0.49.1",
    "snowflake>=1.2.0",
    "snowflake-ml-python>=1.24.0",
    "snowflake-snowpark-python>=1.30.0",
    "toml>=0.10.2",
]

Expected behavior

Hamilton UI server should start such that I can open it via web browser and open the website on localhost.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triagelabel for issues that need to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions