File size: 6,334 Bytes
ea75269
 
 
c636be8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ea75269
 
 
 
 
 
 
 
 
 
aecf55d
ea75269
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221585e
ea75269
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# /// script
# requires-python = ">=3.12"
# dependencies = [
#     "ag-ui-protocol==0.1.9",
#     "aiohappyeyeballs==2.6.1",
#     "aiohttp==3.13.0",
#     "aiosignal==1.4.0",
#     "annotated-types==0.7.0",
#     "anthropic==0.70.0",
#     "anyio==4.11.0",
#     "argcomplete==3.6.2",
#     "attrs==25.4.0",
#     "authlib==1.6.5",
#     "beautifulsoup4==4.14.2",
#     "black==25.9.0",
#     "boto3==1.40.53",
#     "botocore==1.40.53",
#     "cachetools==6.2.1",
#     "certifi==2025.10.5",
#     "cffi==2.0.0",
#     "charset-normalizer==3.4.4",
#     "click==8.3.0",
#     "cobble==0.1.4",
#     "cohere==5.19.0",
#     "colorama==0.4.6",
#     "coloredlogs==15.0.1",
#     "cryptography==46.0.3",
#     "cyclopts==3.24.0",
#     "defusedxml==0.7.1",
#     "distro==1.9.0",
#     "dnspython==2.8.0",
#     "docstring-parser==0.17.0",
#     "docstring-to-markdown==0.17",
#     "docutils==0.22.2",
#     "email-validator==2.3.0",
#     "eval-type-backport==0.2.2",
#     "exceptiongroup==1.3.0",
#     "executing==2.2.1",
#     "fastapi>=0.119.0",
#     "fastavro==1.12.1",
#     "fastmcp==2.12.4",
#     "filelock==3.20.0",
#     "flatbuffers==25.9.23",
#     "frozenlist==1.8.0",
#     "fsspec==2025.9.0",
#     "genai-prices==0.0.32",
#     "google-auth==2.41.1",
#     "google-genai==1.45.0",
#     "googleapis-common-protos==1.70.0",
#     "griffe==1.14.0",
#     "groq==0.32.0",
#     "h11==0.16.0",
#     "hf-xet==1.1.10",
#     "html-for-docx==1.0.10",
#     "httpcore==1.0.9",
#     "httpx==0.28.1",
#     "httpx-sse==0.4.0",
#     "huggingface-hub==0.35.3",
#     "humanfriendly==10.0",
#     "idna==3.11",
#     "importlib-metadata==8.7.0",
#     "invoke==2.2.1",
#     "isodate==0.7.2",
#     "itsdangerous==2.2.0",
#     "jedi==0.19.2",
#     "jiter==0.11.0",
#     "jmespath==1.0.1",
#     "jsonschema==4.25.1",
#     "jsonschema-path==0.3.4",
#     "jsonschema-specifications==2025.9.1",
#     "lazy-object-proxy==1.12.0",
#     "logfire==4.13.2",
#     "logfire-api==4.13.2",
#     "loro==1.8.1",
#     "lxml==6.0.2",
#     "magika==0.6.2",
#     "mammoth==1.11.0",
#     "marimo==0.17.0",
#     "markdown==3.9",
#     "markdown-it-py==4.0.0",
#     "markdownify==1.2.0",
#     "markitdown>=0.1.2",
#     "markupsafe==3.0.3",
#     "mcp==1.17.0",
#     "mdurl==0.1.2",
#     "mistralai==1.9.11",
#     "mistune==3.1.4",
#     "more-itertools==10.8.0",
#     "mpmath==1.3.0",
#     "msgspec-m==0.19.2",
#     "multidict==6.7.0",
#     "mypy-extensions==1.1.0",
#     "narwhals==2.8.0",
#     "nest-asyncio==1.6.0",
#     "nexus-rpc==1.1.0",
#     "numpy==2.3.4",
#     "onnxruntime==1.23.1",
#     "openai==2.3.0",
#     "openapi-core==0.19.5",
#     "openapi-pydantic==0.5.1",
#     "openapi-schema-validator==0.6.3",
#     "openapi-spec-validator==0.7.2",
#     "opentelemetry-api==1.37.0",
#     "opentelemetry-exporter-otlp-proto-common==1.37.0",
#     "opentelemetry-exporter-otlp-proto-http==1.37.0",
#     "opentelemetry-instrumentation==0.58b0",
#     "opentelemetry-instrumentation-httpx==0.58b0",
#     "opentelemetry-proto==1.37.0",
#     "opentelemetry-sdk==1.37.0",
#     "opentelemetry-semantic-conventions==0.58b0",
#     "opentelemetry-util-http==0.58b0",
#     "packaging==25.0",
#     "parse==1.20.2",
#     "parso==0.8.5",
#     "pathable==0.4.4",
#     "pathspec==0.12.1",
#     "pdfminer-six==20250506",
#     "platformdirs==4.5.0",
#     "pluggy==1.6.0",
#     "prompt-toolkit==3.0.52",
#     "propcache==0.4.1",
#     "protobuf==6.33.0",
#     "psutil==7.1.0",
#     "pyasn1==0.6.1",
#     "pyasn1-modules==0.4.2",
#     "pycparser==2.23",
#     "pydantic==2.12.2",
#     "pydantic-ai==1.1.0",
#     "pydantic-ai-slim==1.1.0",
#     "pydantic-core==2.41.4",
#     "pydantic-evals==1.1.0",
#     "pydantic-graph==1.1.0",
#     "pydantic-settings==2.11.0",
#     "pygments==2.19.2",
#     "pymdown-extensions==10.16.1",
#     "pyperclip==1.11.0",
#     "python-dateutil==2.9.0.post0",
#     "python-docx==1.2.0",
#     "python-docx-replace==0.4.4",
#     "python-dotenv==1.1.1",
#     "python-lsp-jsonrpc==1.1.2",
#     "python-lsp-server==1.13.1",
#     "python-multipart==0.0.20",
#     "pytokens==0.2.0",
#     "pyyaml==6.0.3",
#     "referencing==0.36.2",
#     "requests==2.32.5",
#     "rfc3339-validator==0.1.4",
#     "rich==14.2.0",
#     "rich-rst==1.3.2",
#     "rpds-py==0.27.1",
#     "rsa==4.9.1",
#     "s3transfer==0.14.0",
#     "six==1.17.0",
#     "sniffio==1.3.1",
#     "soupsieve==2.8",
#     "sse-starlette==3.0.2",
#     "starlette==0.48.0",
#     "sympy==1.14.0",
#     "temporalio==1.18.0",
#     "tenacity==9.1.2",
#     "tokenizers==0.22.1",
#     "tomlkit==0.13.3",
#     "tqdm==4.67.1",
#     "types-protobuf==6.32.1.20250918",
#     "types-requests==2.32.4.20250913",
#     "typing-extensions==4.15.0",
#     "typing-inspection==0.4.2",
#     "ujson==5.11.0",
#     "urllib3==2.5.0",
#     "uvicorn==0.37.0",
#     "uvloop==0.21.0",
#     "wcwidth==0.2.14",
#     "websockets==15.0.1",
#     "werkzeug==3.1.1",
#     "wrapt==1.17.3",
#     "yarl==1.22.0",
#     "zipp==3.23.0",
# ]
# ///

import logging
import os
from pathlib import Path

import marimo
from dotenv import load_dotenv
from fastapi import FastAPI, Request
from fastapi.responses import RedirectResponse

# Load environment variables
load_dotenv()

# Set up logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

# Get port from environment variable or use default
PORT = int(os.environ.get('PORT', 7860))

root_dir = Path(__file__).parent.parent

ROOTS = [root_dir / 'cicero_jobs']


server = marimo.create_asgi_app(include_code=True)
app_names: list[str] = []

for root in ROOTS:
    for filename in root.iterdir():
        if filename.is_file() and filename.suffix == '.py':
            app_path = root.stem + '/' + filename.stem
            server = server.with_app(path=f'/{app_path}', root=str(filename))
            app_names.append(app_path)

# Create a FastAPI app
app = FastAPI()

logger.info(f'Mounting {len(app_names)} apps')
for app_name in app_names:
    logger.info('  /%s', app_name)


@app.get('/')
async def home(request: Request):
    return RedirectResponse(url='/cicero_jobs/app/')


app.mount('/', server.build())

# Run the server
if __name__ == '__main__':
    import uvicorn

    uvicorn.run(app, host='0.0.0.0', port=PORT, log_level='info')