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

fastapi dev server.py - command error #35

Open
Vasya094 opened this issue Jun 4, 2024 · 3 comments
Open

fastapi dev server.py - command error #35

Vasya094 opened this issue Jun 4, 2024 · 3 comments

Comments

@Vasya094
Copy link

Vasya094 commented Jun 4, 2024

fastapi dev server.py
INFO Using path server.py
INFO Resolved absolute path /Users/rinatkhabibulaev/Desktop/llama-fs/server.py
INFO Searching for package file structure from directories with init.py files
INFO Importing from /Users/rinatkhabibulaev/Desktop/llama-fs

╭─ Python module file ─╮
│ │
│ 🐍 server.py │
│ │
╰──────────────────────╯

INFO Importing module server
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/rinatkhabibulaev/anaconda3/lib/python3.9/site-packages/fastapi_cli/cli.py:174 in dev │
│ │
│ 171 │ │
│ 172 │ Otherwise, it uses the first [bold]FastAPI[/bold] app found in the imported module o │
│ 173 │ """ │
│ ❱ 174 │ _run( │
│ 175 │ │ path=path, │
│ 176 │ │ host=host, │
│ 177 │ │ port=port, │
│ │
│ ╭──────────────── locals ────────────────╮ │
│ │ app = None │ │
│ │ host = '127.0.0.1' │ │
│ │ path = PosixPath('server.py') │ │
│ │ port = 8000 │ │
│ │ proxy_headers = True │ │
│ │ reload = True │ │
│ │ root_path = '' │ │
│ ╰────────────────────────────────────────╯ │
│ │
│ /Users/rinatkhabibulaev/anaconda3/lib/python3.9/site-packages/fastapi_cli/cli.py:65 in _run │
│ │
│ 62 │ proxy_headers: bool = False, │
│ 63 ) -> None: │
│ 64 │ try: │
│ ❱ 65 │ │ use_uvicorn_app = get_import_string(path=path, app_name=app) │
│ 66 │ except FastAPICLIException as e: │
│ 67 │ │ logger.error(str(e)) │
│ 68 │ │ raise typer.Exit(code=1) from None │
│ │
│ ╭──────────────── locals ────────────────╮ │
│ │ app = None │ │
│ │ command = 'dev' │ │
│ │ host = '127.0.0.1' │ │
│ │ path = PosixPath('server.py') │ │
│ │ port = 8000 │ │
│ │ proxy_headers = True │ │
│ │ reload = True │ │
│ │ root_path = '' │ │
│ │ workers = None │ │
│ ╰────────────────────────────────────────╯ │
│ │
│ /Users/rinatkhabibulaev/anaconda3/lib/python3.9/site-packages/fastapi_cli/discover.py:154 in │
│ get_import_string │
│ │
│ 151 │ │ raise FastAPICLIException(f"Path does not exist {path}") │
│ 152 │ mod_data = get_module_data_from_path(path) │
│ 153 │ sys.path.insert(0, str(mod_data.extra_sys_path)) │
│ ❱ 154 │ use_app_name = get_app_name(mod_data=mod_data, app_name=app_name) │
│ 155 │ import_example = Syntax( │
│ 156 │ │ f"from {mod_data.module_import_str} import {use_app_name}", "python" │
│ 157 │ ) │
│ │
│ ╭────────────────────────────────────── locals ───────────────────────────────────────╮ │
│ │ app_name = None │ │
│ │ mod_data = ModuleData( │ │
│ │ │ module_import_str='server', │ │
│ │ │ extra_sys_path=PosixPath('/Users/rinatkhabibulaev/Desktop/llama-fs') │ │
│ │ ) │ │
│ │ path = PosixPath('server.py') │ │
│ ╰─────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Users/rinatkhabibulaev/anaconda3/lib/python3.9/site-packages/fastapi_cli/discover.py:107 in │
│ get_app_name │
│ │
│ 104 │
│ 105 def get_app_name(*, mod_data: ModuleData, app_name: Union[str, None] = None) -> str: │
│ 106 │ try: │
│ ❱ 107 │ │ mod = importlib.import_module(mod_data.module_import_str) │
│ 108 │ except (ImportError, ValueError) as e: │
│ 109 │ │ logger.error(f"Import error: {e}") │
│ 110 │ │ logger.warning( │
│ │
│ ╭────────────────────────────────────── locals ───────────────────────────────────────╮ │
│ │ app_name = None │ │
│ │ mod_data = ModuleData( │ │
│ │ │ module_import_str='server', │ │
│ │ │ extra_sys_path=PosixPath('/Users/rinatkhabibulaev/Desktop/llama-fs') │ │
│ │ ) │ │
│ ╰─────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Users/rinatkhabibulaev/anaconda3/lib/python3.9/importlib/init.py:127 in import_module │
│ │
│ 124 │ │ │ if character != '.': │
│ 125 │ │ │ │ break │
│ 126 │ │ │ level += 1 │
│ ❱ 127 │ return _bootstrap._gcd_import(name[level:], package, level) │
│ 128 │
│ 129 │
│ 130 _RELOADING = {} │
│ │
│ ╭────── locals ──────╮ │
│ │ level = 0 │ │
│ │ name = 'server' │ │
│ │ package = None │ │
│ ╰────────────────────╯ │
│ in _gcd_import:1030 │
│ ╭────── locals ──────╮ │
│ │ level = 0 │ │
│ │ name = 'server' │ │
│ │ package = None │ │
│ ╰────────────────────╯ │
│ in find_and_load:1007 │
│ ╭──────────────────── locals ─────────────────────╮ │
│ │ import
= <function _gcd_import at 0x104e68310> │ │
│ │ module = <object object at 0x104e40060> │ │
│ │ name = 'server' │ │
│ ╰─────────────────────────────────────────────────╯ │
│ in find_and_load_unlocked:986 │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ import
= <function _gcd_import at 0x104e68310> │ │
│ │ name = 'server' │ │
│ │ parent = '' │ │
│ │ path = None │ │
│ │ spec = ModuleSpec(name='server', loader=<_frozen_importlib_external.SourceFileLoader │ │
│ │ object at 0x1076dd250>, │ │
│ │ origin='/Users/rinatkhabibulaev/Desktop/llama-fs/server.py') │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ in _load_unlocked:680 │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ module = <module 'server' from '/Users/rinatkhabibulaev/Desktop/llama-fs/server.py'> │ │
│ │ spec = ModuleSpec(name='server', loader=<_frozen_importlib_external.SourceFileLoader │ │
│ │ object at 0x1076dd250>, │ │
│ │ origin='/Users/rinatkhabibulaev/Desktop/llama-fs/server.py') │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ in exec_module:850 │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ code = <code object at 0x1076a5ea0, file │ │
│ │ "/Users/rinatkhabibulaev/Desktop/llama-fs/server.py", line 1> │ │
│ │ module = <module 'server' from '/Users/rinatkhabibulaev/Desktop/llama-fs/server.py'> │ │
│ │ self = <_frozen_importlib_external.SourceFileLoader object at 0x1076dd250> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ in _call_with_frames_removed:228 │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ args = ( │ │
│ │ │ <code object at 0x1076a5ea0, file │ │
│ │ "/Users/rinatkhabibulaev/Desktop/llama-fs/server.py", line 1>, │ │
│ │ │ { │ │
│ │ │ │ 'name': 'server', │ │
│ │ │ │ 'doc': None, │ │
│ │ │ │ 'package': '', │ │
│ │ │ │ 'loader': <_frozen_importlib_external.SourceFileLoader object at │ │
│ │ 0x1076dd250>, │ │
│ │ │ │ 'spec': ModuleSpec(name='server', │ │
│ │ loader=<_frozen_importlib_external.SourceFileLoader object at 0x1076dd250>, │ │
│ │ origin='/Users/rinatkhabibulaev/Desktop/llama-fs/server.py'), │ │
│ │ │ │ 'file': '/Users/rinatkhabibulaev/Desktop/llama-fs/server.py', │ │
│ │ │ │ 'cached': │ │
│ │ '/Users/rinatkhabibulaev/Desktop/llama-fs/pycache/server.cpython-39.pyc', │ │
│ │ │ │ 'builtins': { │ │
│ │ │ │ │ 'name': 'builtins', │ │
│ │ │ │ │ 'doc': 'Built-in functions, exceptions, and other │ │
│ │ objects.\n\nNoteworthy: None is the `nil'+46, │ │
│ │ │ │ │ 'package': '', │ │
│ │ │ │ │ 'loader': <class '_frozen_importlib.BuiltinImporter'>, │ │
│ │ │ │ │ 'spec': ModuleSpec(name='builtins', loader=<class │ │
│ │ '_frozen_importlib.BuiltinImporter'>, origin='built-in'), │ │
│ │ │ │ │ 'build_class': , │ │
│ │ │ │ │ 'import': , │ │
│ │ │ │ │ 'abs': , │ │
│ │ │ │ │ 'all': , │ │
│ │ │ │ │ 'any': , │ │
│ │ │ │ │ ... +143 │ │
│ │ │ │ }, │ │
│ │ │ │ 'json': <module 'json' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/json/init.py'>, │ │
│ │ │ │ 'os': <module 'os' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/os.py'>, │ │
│ │ │ │ ... +22 │ │
│ │ │ } │ │
│ │ ) │ │
│ │ f = │ │
│ │ kwds = {} │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Users/rinatkhabibulaev/Desktop/llama-fs/server.py:26 in │
│ │
│ 23 from termcolor import colored │
│ 24 from watchdog.observers import Observer │
│ 25 │
│ ❱ 26 from src.loader import get_dir_summaries │
│ 27 from src.tree_generator import create_file_tree │
│ 28 from src.watch_utils import Handler │
│ 29 from src.watch_utils import create_file_tree as create_watch_file_tree │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ BaseModel = <class 'pydantic.main.BaseModel'> │ │
│ │ BOX_LIGHT = { │ │
│ │ │ 'UP_AND_RIGHT': '└', │ │
│ │ │ 'HORIZONTAL': '─', │ │
│ │ │ 'VERTICAL': '│', │ │
│ │ │ 'VERTICAL_AND_RIGHT': '├' │ │
│ │ } │ │
│ │ BoxStyle = <class 'asciitree.drawing.BoxStyle'> │ │
│ │ colorama = <module 'colorama' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/site-packages/colo… │ │
│ │ colored = <function colored at 0x16fa8fb80> │ │
│ │ CORSMiddleware = <class 'starlette.middleware.cors.CORSMiddleware'> │ │
│ │ defaultdict = <class 'collections.defaultdict'> │ │
│ │ FastAPI = <class 'fastapi.applications.FastAPI'> │ │
│ │ Groq = <class 'groq.Groq'> │ │
│ │ HTTPException = <class 'fastapi.exceptions.HTTPException'> │ │
│ │ json = <module 'json' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/json/init.py'> │ │
│ │ LeftAligned = <class 'asciitree.LeftAligned'> │ │
│ │ Observer = <class 'watchdog.observers.fsevents.FSEventsObserver'> │ │
│ │ ollama = <module 'ollama' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/site-packages/olla… │ │
│ │ Optional = typing.Optional │ │
│ │ os = <module 'os' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/os.py'> │ │
│ │ Path = <class 'pathlib.Path'> │ │
│ │ pathlib = <module 'pathlib' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/pathlib.py'> │ │
│ │ queue = <module 'queue' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/queue.py'> │ │
│ │ shutil = <module 'shutil' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/shutil.py'> │ │
│ │ SimpleDirectoryReader = <class 'llama_index.core.readers.file.base.SimpleDirectoryReader'> │ │
│ │ StreamingResponse = <class 'starlette.responses.StreamingResponse'> │ │
│ │ threading = <module 'threading' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/threading.py'> │ │
│ │ time = <module 'time' (built-in)> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Users/rinatkhabibulaev/Desktop/llama-fs/src/loader.py:6 in │
│ │
│ 3 import os │
│ 4 from collections import defaultdict │
│ 5 │
│ ❱ 6 import agentops │
│ 7 import colorama │
│ 8 import ollama │
│ 9 import weave │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ asyncio = <module 'asyncio' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/asyncio/init.py'> │ │
│ │ defaultdict = <class 'collections.defaultdict'> │ │
│ │ json = <module 'json' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/json/init.py'> │ │
│ │ os = <module 'os' from '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/os.py'> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Users/rinatkhabibulaev/anaconda3/lib/python3.9/site-packages/agentops/init.py:5 in │
│ │
│ 2 import os │
│ 3 import logging │
│ 4 from typing import Optional, List, Union │
│ ❱ 5 from .client import Client │
│ 6 from .config import Configuration │
│ 7 from .event import Event, ActionEvent, LLMEvent, ToolEvent, ErrorEvent │
│ 8 from .enums import Models │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ enums = <module 'agentops.enums' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/site-packages/agentops/enums.… │ │
│ │ helpers = <module 'agentops.helpers' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/site-packages/agentops/helper… │ │
│ │ List = typing.List │ │
│ │ log_config = <module 'agentops.log_config' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/site-packages/agentops/log_co… │ │
│ │ logging = <module 'logging' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/logging/init.py'> │ │
│ │ Optional = typing.Optional │ │
│ │ os = <module 'os' from '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/os.py'> │ │
│ │ Union = typing.Union │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Users/rinatkhabibulaev/anaconda3/lib/python3.9/site-packages/agentops/client.py:20 in │
│ │
│ 17 from uuid import UUID, uuid4 │
│ 18 from typing import Optional, List, Union │
│ 19 │
│ ❱ 20 from .event import ActionEvent, ErrorEvent, Event │
│ 21 from .enums import EndState │
│ 22 from .helpers import ( │
│ 23 │ get_ISO_time, │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ atexit = <module 'atexit' (built-in)> │ │
│ │ Decimal = <class 'decimal.Decimal'> │ │
│ │ inspect = <module 'inspect' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/inspect.py'> │ │
│ │ List = typing.List │ │
│ │ logging = <module 'logging' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/logging/init.py'> │ │
│ │ Optional = typing.Optional │ │
│ │ os = <module 'os' from '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/os.py'> │ │
│ │ signal = <module 'signal' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/signal.py'> │ │
│ │ sys = <module 'sys' (built-in)> │ │
│ │ threading = <module 'threading' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/threading.py'> │ │
│ │ traceback = <module 'traceback' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/traceback.py'> │ │
│ │ Union = typing.Union │ │
│ │ UUID = <class 'uuid.UUID'> │ │
│ │ uuid4 = <function uuid4 at 0x10550c430> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Users/rinatkhabibulaev/anaconda3/lib/python3.9/site-packages/agentops/event.py:17 in │
│ │
│ 14 │
│ 15 │
│ 16 @DataClass
│ ❱ 17 class Event: │
│ 18 │ """ │
│ 19 │ Abstract base class for events that will be recorded. Should not be instantiated dir │
│ 20 │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ Any = typing.Any │ │
│ │ asdict = <function asdict at 0x10571cdc0> │ │
│ │ check_call_stack_for_agent_id = <function check_call_stack_for_agent_id at 0x16fac8d30> │ │
│ │ dataclass = <function dataclass at 0x10571cb80> │ │
│ │ Dict = typing.Dict │ │
│ │ EventType = <enum 'EventType'> │ │
│ │ field = <function field at 0x1056fb5e0> │ │
│ │ get_ISO_time = <function get_ISO_time at 0x16fac8a60> │ │
│ │ List = typing.List │ │
│ │ Models = <enum 'Models'> │ │
│ │ Optional = typing.Optional │ │
│ │ Sequence = typing.Sequence │ │
│ │ traceback = <module 'traceback' from │ │
│ │ '/Users/rinatkhabibulaev/anaconda3/lib/python3.9/traceback.… │ │
│ │ Union = typing.Union │ │
│ │ UUID = <class 'uuid.UUID'> │ │
│ │ uuid4 = <function uuid4 at 0x10550c430> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /Users/rinatkhabibulaev/anaconda3/lib/python3.9/site-packages/agentops/event.py:41 in Event │
│ │
│ 38 │ │
│ 39 │ event_type: EventType │
│ 40 │ params: Optional[dict] = None │
│ ❱ 41 │ returns: Optional[str | List[str]] = None │
│ 42 │ init_timestamp: str = field(default_factory=get_ISO_time) │
│ 43 │ end_timestamp: Optional[str] = None │
│ 44 │ agent_id: Optional[UUID] = field(default_factory=check_call_stack_for_agent_id) │
│ │
│ ╭──── locals ────╮ │
│ │ params = None │ │
│ │ returns = None │ │
│ ╰────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: unsupported operand type(s) for |: 'type' and '_GenericAlias'

@Vasya094
Copy link
Author

Vasya094 commented Jun 4, 2024

python --version
Python 3.11.4
macOS m2

@vffuunnyy
Copy link

vffuunnyy commented Jun 4, 2024

python --version Python 3.11.4 macOS m2

but in the log file python3.9.

If it's not working on 3.11 try to use 3.12

@seghier
Copy link

seghier commented Jun 26, 2024

I also got many errors and i use python

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

No branches or pull requests

3 participants