Spaces:
Sleeping
Sleeping
Daniel Ecer commited on
Commit ·
28c297e
1
Parent(s): 6081d80
initial dummy app
Browse files- .gitignore +10 -0
- .python-version +1 -0
- Makefile +57 -0
- fngradio_various_api_mcp/__init__.py +0 -0
- fngradio_various_api_mcp/__main__.py +13 -0
- fngradio_various_api_mcp/app.py +14 -0
- pyproject.toml +39 -0
- setup.cfg +2 -0
- tests/conftest.py +17 -0
- tests/test_app.py +9 -0
- uv.lock +0 -0
.gitignore
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Python-generated files
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[oc]
|
| 4 |
+
build/
|
| 5 |
+
dist/
|
| 6 |
+
wheels/
|
| 7 |
+
*.egg-info
|
| 8 |
+
|
| 9 |
+
# Virtual environments
|
| 10 |
+
.venv
|
.python-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
3.13
|
Makefile
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/make -f
|
| 2 |
+
|
| 3 |
+
VENV = .venv
|
| 4 |
+
UV = uv
|
| 5 |
+
PIP = $(VENV)/bin/pip
|
| 6 |
+
PYTHON = $(VENV)/bin/python
|
| 7 |
+
|
| 8 |
+
UV_RUN = $(UV) run --no-sync
|
| 9 |
+
|
| 10 |
+
PYTEST_WATCH_MODULES =
|
| 11 |
+
ARGS =
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
venv-clean:
|
| 15 |
+
@if [ -d "$(VENV)" ]; then \
|
| 16 |
+
rm -rf "$(VENV)"; \
|
| 17 |
+
fi
|
| 18 |
+
|
| 19 |
+
venv-create:
|
| 20 |
+
$(UV) venv
|
| 21 |
+
|
| 22 |
+
dev-install:
|
| 23 |
+
$(UV) sync --frozen --all-extras --dev
|
| 24 |
+
|
| 25 |
+
dev-upgrade-all:
|
| 26 |
+
$(UV) sync --upgrade
|
| 27 |
+
|
| 28 |
+
dev-venv: venv-create dev-install
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
dev-flake8:
|
| 32 |
+
$(UV_RUN) -m flake8 fngradio_various_api_mcp tests
|
| 33 |
+
|
| 34 |
+
dev-pylint:
|
| 35 |
+
$(UV_RUN) -m pylint fngradio_various_api_mcp tests
|
| 36 |
+
|
| 37 |
+
dev-mypy:
|
| 38 |
+
$(UV_RUN) -m mypy --check-untyped-defs fngradio_various_api_mcp tests
|
| 39 |
+
|
| 40 |
+
dev-lint: dev-flake8 dev-pylint dev-mypy
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
dev-unit-tests:
|
| 44 |
+
$(UV_RUN) -m pytest -vv
|
| 45 |
+
|
| 46 |
+
dev-watch:
|
| 47 |
+
$(UV_RUN) -m pytest_watcher \
|
| 48 |
+
--runner=$(VENV)/bin/python \
|
| 49 |
+
. \
|
| 50 |
+
-m pytest -vv $(PYTEST_WATCH_MODULES)
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
dev-test: dev-lint dev-unit-tests
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
dev-start:
|
| 57 |
+
$(UV_RUN) -m fngradio_various_api_mcp
|
fngradio_various_api_mcp/__init__.py
ADDED
|
File without changes
|
fngradio_various_api_mcp/__main__.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
|
| 3 |
+
from fngradio_various_api_mcp.app import create_app
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def main() -> None:
|
| 7 |
+
app = create_app()
|
| 8 |
+
app.tabbed().launch(mcp_server=True)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
if __name__ == "__main__":
|
| 12 |
+
logging.basicConfig(level=logging.INFO)
|
| 13 |
+
main()
|
fngradio_various_api_mcp/app.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fngradio import FnGradioApp # type: ignore[import-untyped]
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def create_app() -> FnGradioApp:
|
| 5 |
+
app = FnGradioApp()
|
| 6 |
+
|
| 7 |
+
@app.interface()
|
| 8 |
+
def add_int_numbers(a: int, b: int) -> int:
|
| 9 |
+
"""
|
| 10 |
+
Add two int numbers
|
| 11 |
+
"""
|
| 12 |
+
return a + b
|
| 13 |
+
|
| 14 |
+
return app
|
pyproject.toml
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "fngradio-various-api-mcp"
|
| 3 |
+
version = "0.0.1"
|
| 4 |
+
description = "Various public APIs exposed as MCP via Gradio using fngradio"
|
| 5 |
+
readme = "README.md"
|
| 6 |
+
requires-python = ">=3.13"
|
| 7 |
+
dependencies = [
|
| 8 |
+
"fngradio>=0.0.4",
|
| 9 |
+
"gradio[mcp]>=5.42.0",
|
| 10 |
+
]
|
| 11 |
+
|
| 12 |
+
[dependency-groups]
|
| 13 |
+
dev = [
|
| 14 |
+
"flake8>=7.3.0",
|
| 15 |
+
"mypy>=1.17.1",
|
| 16 |
+
"pylint>=3.3.8",
|
| 17 |
+
"pytest>=8.4.1",
|
| 18 |
+
"pytest-watcher>=0.4.3",
|
| 19 |
+
]
|
| 20 |
+
|
| 21 |
+
[tool.pylint.'MESSAGES CONTROL']
|
| 22 |
+
max-line-length = 100
|
| 23 |
+
disable = """
|
| 24 |
+
missing-docstring,
|
| 25 |
+
too-few-public-methods,
|
| 26 |
+
duplicate-code
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
[tool.pytest.ini_options]
|
| 30 |
+
filterwarnings = [
|
| 31 |
+
"error"
|
| 32 |
+
]
|
| 33 |
+
|
| 34 |
+
[tool.pytest-watcher]
|
| 35 |
+
now = true
|
| 36 |
+
clear = false
|
| 37 |
+
delay = 0.2
|
| 38 |
+
runner = ".venv/bin/python"
|
| 39 |
+
runner_args = ["-m", "pytest"]
|
setup.cfg
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[flake8]
|
| 2 |
+
max-line-length = 100
|
tests/conftest.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
import logging
|
| 3 |
+
import pytest
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
@pytest.fixture(scope='session', autouse=True)
|
| 7 |
+
def setup_logging():
|
| 8 |
+
logging.basicConfig(level='INFO')
|
| 9 |
+
for name in ['tests', 'fngradio_various_api_mcp']:
|
| 10 |
+
logging.getLogger(name).setLevel('DEBUG')
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
@pytest.fixture(autouse=True, scope='session')
|
| 14 |
+
def ensure_thread_loop():
|
| 15 |
+
loop = asyncio.new_event_loop()
|
| 16 |
+
asyncio.set_event_loop(loop)
|
| 17 |
+
yield
|
tests/test_app.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fngradio import FnGradioApp # type: ignore[import-untyped]
|
| 2 |
+
|
| 3 |
+
from fngradio_various_api_mcp.app import create_app
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class TestApp:
|
| 7 |
+
def test_should_not_fail(self):
|
| 8 |
+
app = create_app()
|
| 9 |
+
assert isinstance(app, FnGradioApp)
|
uv.lock
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|