Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6ce6fe1
Add middleware.io integration and logging to profiler.py; create run.…
surendhar-palanisamy Nov 10, 2025
82a8c8b
Integrate Middleware.io for profiling and telemetry; enhance UnavServ…
surendhar-palanisamy Nov 10, 2025
ed9573a
Remove sample file comment from profiler.py
surendhar-palanisamy Nov 10, 2025
1bf2a02
Restore run.sh script for middleware execution
surendhar-palanisamy Nov 10, 2025
06f77b9
Refactor UnavServer to remove unused tracing spans in localization an…
surendhar-palanisamy Nov 10, 2025
84053c1
Refactor UnavServer to streamline tracing spans and enhance middlewar…
surendhar-palanisamy Nov 10, 2025
422e38f
Implement code changes to enhance functionality and improve performance
surendhar-palanisamy Nov 10, 2025
c6e9fd9
Refactor UnavServer to rename tracing span from 'planner_full_pipelin…
surendhar-palanisamy Nov 10, 2025
f4ac80c
Refactor ensure_maps_loaded to enhance tracing and improve selective …
surendhar-palanisamy Nov 10, 2025
81b2425
Refactor ensure_maps_loaded to rename tracing span from 'ensure_maps_…
surendhar-palanisamy Nov 10, 2025
e9b3dcc
Refactor tracing spans in UnavServer to improve clarity by renaming t…
surendhar-palanisamy Nov 10, 2025
2df4316
Add tracing span for loading maps and features in selective localizer
surendhar-palanisamy Nov 10, 2025
1314f09
Refactor tracing spans in UnavServer to improve clarity by appending …
surendhar-palanisamy Nov 10, 2025
685c8c7
Enhance tracing for map and feature loading in UnavServer by adding l…
surendhar-palanisamy Nov 12, 2025
314ac6d
Remove L4 GPU from UnavServer configuration to streamline resource al…
surendhar-palanisamy Nov 12, 2025
7575728
Add tracing span for pose generation during localization in UnavServer
surendhar-palanisamy Nov 12, 2025
bae40b6
Refactor map loading logic in UnavServer to improve clarity and maint…
surendhar-palanisamy Nov 12, 2025
66675f5
Add tracing span for map loading in ensure_maps_loaded method in Unav…
surendhar-palanisamy Nov 12, 2025
fbad3b4
Branch from profiling (#56)
surendhar-palanisamy Nov 12, 2025
24fc9c9
Increase scaledown window in UnavServer configuration to improve reso…
surendhar-palanisamy Nov 12, 2025
45a0209
Remove unnecessary tracing span for pose generation in UnavServer loc…
surendhar-palanisamy Nov 12, 2025
10880dc
Add fine-grained tracing to UNavLocalizer methods via monkey-patching
surendhar-palanisamy Nov 18, 2025
9ddcb49
Refine monkey-patching of UNavLocalizer methods to target specific me…
surendhar-palanisamy Nov 18, 2025
06ecdfc
Enhance monkey-patching in UNavServer by combining pipeline methods w…
surendhar-palanisamy Nov 18, 2025
943a65d
Refactor scaling configuration and improve method wrapping for tracin…
surendhar-palanisamy Nov 18, 2025
edf0bfa
Reduce scaledown window from 200 to 60 for improved resource manageme…
surendhar-palanisamy Nov 18, 2025
2fcbabb
Refactor UnavServer initialization and middleware configuration for i…
surendhar-palanisamy Nov 18, 2025
6d0ecf5
Add unique call ID to planner tracing for improved tracking
surendhar-palanisamy Nov 18, 2025
4b0ea4a
Set scaledown window to 500 for improved resource management in UnavS…
surendhar-palanisamy Nov 18, 2025
64cdfe6
Reduce scaledown window from 500 to 60 for improved resource manageme…
surendhar-palanisamy Nov 19, 2025
90fe390
Remove unused image processing logic and GPU debug information for cl…
surendhar-palanisamy Nov 19, 2025
0b50898
Update GPU type to A10G and set scaledown window to 500 for improved …
surendhar-palanisamy Nov 20, 2025
c070c2a
Change GPU type to T4 and set scaledown window to 60 for improved res…
surendhar-palanisamy Nov 24, 2025
589e21a
Implement UNavLocalizer class for visual place recognition and pose e…
surendhar-palanisamy Nov 24, 2025
6168411
Add pose refinement monkey patching for improved tracing in UNavServer
surendhar-palanisamy Nov 24, 2025
9920f09
Add monkey patching for matching and RANSAC functions in UNavServer
surendhar-palanisamy Nov 25, 2025
dfc7ec7
Add feature extraction monkey patching for enhanced tracing in UNavSe…
surendhar-palanisamy Nov 25, 2025
fdb0d00
Enhance tracing for Superpoint feature extraction with dynamic import…
surendhar-palanisamy Nov 25, 2025
c7cc91d
Add tracing for LightGlue's internal methods to enhance debugging cap…
surendhar-palanisamy Nov 25, 2025
a3ea490
Refactor extract_query_features and local feature extraction methods …
surendhar-palanisamy Nov 25, 2025
c47bde1
Refactor monkey patching for localizer methods to improve tracing fle…
surendhar-palanisamy Nov 25, 2025
2c99289
Update GPU configuration in UnavServer to support additional models
surendhar-palanisamy Nov 27, 2025
d9486e9
Add scaledown_window parameter to UnavServer configuration
surendhar-palanisamy Nov 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions profiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import modal
import time
import logging

image = (
modal.Image.debian_slim(python_version="3.11")
.apt_install("git")
.pip_install("middleware-io", "middleware-io[profiling]")
.env(
{
"MW_SERVICE_NAME": "MyPythonApp-Final",
"MW_APM_COLLECT_PROFILING": "true",
"MW_TRACKER": "true",
"MW_CONSOLE_EXPORTER": "false",
# Crucial for debugging logs
"OTEL_SERVICE_NAME": "modal-unav-server",
}
)
.run_commands(
"middleware-bootstrap -a install",
"echo '#!/bin/sh' > /root/run.sh",
"echo 'exec middleware-run \"$@\"' >> /root/run.sh",
"chmod +x /root/run.sh",
)
.dockerfile_commands('ENTRYPOINT ["/root/run.sh"]')
)

app = modal.App("hello-world-app", image=image)


@app.function(secrets=[modal.Secret.from_name("middleware")])
def hello():
from middleware import mw_tracker, MWOptions
from opentelemetry import trace
import os

api_key = os.environ.get("MW_API_KEY")
target = os.environ.get("MW_TARGET")

if not api_key or not target:
raise ValueError("MW_API_KEY and MW_TARGET environment variables must be set")

mw_tracker(
MWOptions(
access_token=api_key,
target=target,
service_name="MyPythonApp-Final",
console_exporter=False,
log_level="INFO",
collect_profiling=True,
collect_traces=True,
collect_metrics=True,
)
)

tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("hello_function") as span:

def child_function_1():
with tracer.start_as_current_span("child_function_1") as child_span:
child_span.set_attribute("operation", "task_1")
time.sleep(0.5) # 0.5 seconds

def child_function_2():
with tracer.start_as_current_span("child_function_2") as child_span:
child_span.set_attribute("operation", "task_2")
time.sleep(1.0) # 1 second

def child_function_3():
with tracer.start_as_current_span("child_function_3") as child_span:
child_span.set_attribute("operation", "task_3")
time.sleep(1.5) # 1.5 seconds

logging.info(
"Function started. Middleware is now correctly wrapping the Modal worker."
)

# Call child functions
child_function_1()
child_function_2()
child_function_3()

logging.info("Processing complete. Check logs for telemetry output.")
return {
"status": "success",
"message": "hello world from a non-crashing container",
}


@app.local_entrypoint()
def main():
# This is not used for deployment, only for local testing.
pass
Loading