-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add python support * Fix route reporting Also includes some minor cleanup changes * Add ruff formatter/linter * Fix linting issues * Add mypy * Add pyhumps and types-request as temp example deps * Export measure And fix measure as well as add support for traceparent * Don't record requests with `x-fpx-route-inspector` Request with this header key set to enabled will not be recorded * Use fpx_endpoint in setup_span_instrumentation also: minor cleanup * Cleanup & organize imports * Move JSONSpanExporter to seperate file * Update temporary dependencies for example * Use dataclasses-json * Tweak tailwind config to fix build * Rename `status_code` to `code` for the ts api * Add logging to JSONSpanExporter * Add some docstrings * Add a test * Update README * Handle check_error And please mypy * Fix running studio for python projects * Bump package to 0.2.1 As the published version (0.2.0) wasn't up-to-date Also: * fix linting issues * remove superfluous dependencies for python-fastapi example * Fix formatting complaints * Remove unused Tiltfile * Bump version for types package * bump @fiberplane/source-analysis version * bump version for @fiberplane/studio * Bump version * Remove unsupported request headers * Bump version of studio * Rename fpx.py to fpxpy * Improve typescript not found messaging * Update readme * Tweak readme (and fix some formatting issues * Add a logger * Change the FastAPI supported range (and change the link to the fastapi package in the readme) * update model protocol sdk * .log to .error + add body handling Changed console.log to console.error so they don't clash with stdio transport messages. Also make sure the send request tool can handle body payloads * Add logging support * Update readme * Fix formatting * Tweak python-fastapi example docs * update mcp version * Add py.typed file * Add mypy is a devdep to python-fastapi * Updaet @measure info slightly * Bump version of fpxpy * Update version for @fiberplane/source-analysis * Please the biome formatting overlord --------- Co-authored-by: Jacco Flenter <[email protected]> Co-authored-by: Laurynas Keturakis <[email protected]>
- Loading branch information
1 parent
76d0039
commit bc68526
Showing
38 changed files
with
3,812 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": "0.13.0-canary.1", | ||
"version": "0.13.0", | ||
"name": "@fiberplane/studio", | ||
"description": "Local development debugging interface for Hono apps", | ||
"author": "Fiberplane<[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# python-fastapi example | ||
|
||
This project uses `uv`. To run: | ||
|
||
``` | ||
$ uv sync --frozen | ||
$ FPX_ENDPOINT=http://localhost:8788/v1/traces uv run fastapi dev main.py | ||
``` | ||
|
||
Of course you also need to run studio next to it, for that you need [`npx`](https://docs.npmjs.com/cli/v7/commands/npx) . So you can run: | ||
|
||
``` | ||
npx @fiberplane/studio | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from typing import Union | ||
import logging | ||
|
||
from time import sleep | ||
|
||
from fastapi import FastAPI | ||
from fpxpy import measure, setup | ||
|
||
|
||
app = FastAPI() | ||
setup(app) | ||
|
||
# Example logger | ||
logger = logging.getLogger(__name__) | ||
# Set the log level to log everything | ||
logger.setLevel(logging.DEBUG) | ||
|
||
|
||
@app.get("/") | ||
def read_root(): | ||
""" | ||
Example index that returns a JSON object | ||
""" | ||
loop() | ||
return {"Hello": "World"} | ||
|
||
|
||
@measure(name="loop") | ||
def loop(n: int = 10) -> None: | ||
for i in range(n): | ||
sleep(0.1) | ||
# Log the loop number | ||
# This will be captured by FPX | ||
# Unfortunately this will not appear in the terminal console | ||
# When using `FPX_ENDPOINT=http://localhost:8788/v1/traces uv run fastapi dev ./main.py` | ||
logger.info("loop %i", i) | ||
|
||
|
||
@app.get("/hello") | ||
async def root(): | ||
return {"message": "Hello World"} | ||
|
||
|
||
@app.get("/items/{item_id}") | ||
def read_item(item_id: int, q: Union[str, None] = None): | ||
""" | ||
Endpoint that returns JSON object with some of the parameters | ||
Args: | ||
item_id (int): _description_ | ||
q (Union[str, None], optional): _description_. Defaults to None. | ||
Returns: | ||
_type_: _description_ | ||
""" | ||
return {"item_id": item_id, "q": q} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[project] | ||
name = "python-fastapi" | ||
version = "0.1.0" | ||
description = "Add your description here" | ||
readme = "README.md" | ||
requires-python = ">=3.10" | ||
dependencies = [ | ||
"fastapi[standard]>=0.115.6", | ||
"fpxpy>=0.2.0", | ||
] | ||
|
||
[dependency-groups] | ||
dev = [ | ||
"mypy>=1.14.1", | ||
] |
Oops, something went wrong.