exaloop / exaloop/codon

Unable to get Fast API working

Open
#642 3 comments 2 reactions 1 assignee Claimed by @inumanag View on GitHub
bug
Dominant language
Python
Stars
16.8k
Forks
603
Avg merge
4d 23h
Merged PRs (30d)
6

Description

See here:

I tried to get fast api working with codon. I like the idea of getting quite a bit of speed out of python.

https://github.com/fastapi/fastapi/discussions/10096

This is probably user error but I was not able to get their sample hello world running with codon. It might be a dependency issue?

Here is the simpliest code I could come up with:

```

from python import fastapi as fast

from typing import Union

#from fastapi import FastAPI

app = fast.FastAPI()

@app.get("/")
def read_root():
return {"Hello": "World"}
```

I also tried without the decorator with the same error below:
```python
from python import fastapi as fast

from typing import Union

app = fast.FastAPI()

def read_root(request):
return {"Hello": "World"}

app.router.add_api_route("/", read_root, methods=["GET"])
```

Error:
```
codon run main.py
PyError: ((), ()) is not a callable object

Raised from: pyobj.exc_check:0
/root/.codon/lib/codon/stdlib/internal/python.codon:1198:13

Backtrace:
[0x7f37143126b7] pyobj.exc_check:0.882 at /root/.codon/lib/codon/stdlib/internal/python.codon:1198:13
[0x7f37143126f0] pyobj.exc_wrap:0[Ptr[byte],Ptr[byte]].883 at /root/.codon/lib/codon/stdlib/internal/python.codon:1201:9
[0x7f3714313a60] pyobj:pyobj.__call__:0[pyobj,Tuple[Partial.N.read_root:0[read_root:0,Tuple,KwTuple.N0]],KwTuple.N0].1033 at /root/.codon/lib/codon/stdlib/internal/python.codon:1225:68
[0x7f37143153d2] main.0 at /workspace/fast-api/main.py:11:1
Aborted
```

I made sure `export CODON_PYTHON=/usr/lib/python3.12/config-3.12-x86_64-linux-gnu/libpython3.12.so` is populated and other codon examples from the main site works on the machine. Im using ubuntu:latest docker container but was able to reproduce on a bare metal ubuntu machine as well.

Any ideas?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.