ioc-scope-api 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ioc_scope_api-1.0.0/.env.example +11 -0
- ioc_scope_api-1.0.0/.gitignore +180 -0
- ioc_scope_api-1.0.0/Dockerfile +48 -0
- ioc_scope_api-1.0.0/Makefile +14 -0
- ioc_scope_api-1.0.0/PKG-INFO +306 -0
- ioc_scope_api-1.0.0/README.md +279 -0
- ioc_scope_api-1.0.0/Taskfile.yml +40 -0
- ioc_scope_api-1.0.0/data/clickhouse/otel_traces.sql +43 -0
- ioc_scope_api-1.0.0/data/clickhouse/trace_labels.sql +9 -0
- ioc_scope_api-1.0.0/data/csv/derived_metrics.csv +11 -0
- ioc_scope_api-1.0.0/data/csv/derived_metrics_PassiveEvalAgents.csv +11 -0
- ioc_scope_api-1.0.0/data/csv/otel_traces.csv +542 -0
- ioc_scope_api-1.0.0/data/csv/otel_traces_10.csv +12 -0
- ioc_scope_api-1.0.0/data/csv/otel_traces_working.csv +524 -0
- ioc_scope_api-1.0.0/data/postgres/otel_traces.sql +43 -0
- ioc_scope_api-1.0.0/data/sql/otel_traces.sql +43 -0
- ioc_scope_api-1.0.0/deploy/docker-compose.yml +73 -0
- ioc_scope_api-1.0.0/pyproject.toml +61 -0
- ioc_scope_api-1.0.0/scope/__init__.py +27 -0
- ioc_scope_api-1.0.0/scope/api/__init__.py +119 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/__init__.py +2 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/api.py +71 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/__init__.py +2 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/agentic_protocols_metrics.py +39 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/applications.py +440 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/cache.py +50 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/concepts.py +123 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/features.py +19 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/helpers.py +65 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/kg.py +195 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/labels.py +71 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/live_topology.py +89 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/metrics.py +1014 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/reasoning.py +62 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/semanticgroups.py +144 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/sessions.py +339 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/spans.py +41 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/symbolic.py +186 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/ui.py +145 -0
- ioc_scope_api-1.0.0/scope/api/api_v1/endpoints/waste_estimation.py +182 -0
- ioc_scope_api-1.0.0/scope/api/api_v2/__init__.py +3 -0
- ioc_scope_api-1.0.0/scope/api/api_v2/api.py +23 -0
- ioc_scope_api-1.0.0/scope/api/api_v2/endpoints/__init__.py +3 -0
- ioc_scope_api-1.0.0/scope/api/api_v2/endpoints/metrics.py +193 -0
- ioc_scope_api-1.0.0/scope/app.py +30 -0
- ioc_scope_api-1.0.0/scope/cache.py +64 -0
- ioc_scope_api-1.0.0/scope/client/__init__.py +27 -0
- ioc_scope_api-1.0.0/scope/client/_concepts.py +137 -0
- ioc_scope_api-1.0.0/scope/client/_kg.py +64 -0
- ioc_scope_api-1.0.0/scope/client/_labels.py +86 -0
- ioc_scope_api-1.0.0/scope/client/_live_topology.py +912 -0
- ioc_scope_api-1.0.0/scope/client/_metrics.py +561 -0
- ioc_scope_api-1.0.0/scope/client/_semanticgroups.py +166 -0
- ioc_scope_api-1.0.0/scope/client/_sessions.py +168 -0
- ioc_scope_api-1.0.0/scope/client/_symbolic.py +1354 -0
- ioc_scope_api-1.0.0/scope/client/_ui.py +599 -0
- ioc_scope_api-1.0.0/scope/client/agentic_protocols.py +289 -0
- ioc_scope_api-1.0.0/scope/client/application_charts.py +1786 -0
- ioc_scope_api-1.0.0/scope/client/applications.py +2246 -0
- ioc_scope_api-1.0.0/scope/client/base.py +49 -0
- ioc_scope_api-1.0.0/scope/client/cognition_protocols.py +302 -0
- ioc_scope_api-1.0.0/scope/client/constants.py +81 -0
- ioc_scope_api-1.0.0/scope/client/dal.py +2382 -0
- ioc_scope_api-1.0.0/scope/client/failures.py +70 -0
- ioc_scope_api-1.0.0/scope/client/local.py +161 -0
- ioc_scope_api-1.0.0/scope/client/mock/__init__.py +7 -0
- ioc_scope_api-1.0.0/scope/client/mock/client.py +1034 -0
- ioc_scope_api-1.0.0/scope/client/sessions.py +1688 -0
- ioc_scope_api-1.0.0/scope/client/spans.py +95 -0
- ioc_scope_api-1.0.0/scope/client/utils.py +392 -0
- ioc_scope_api-1.0.0/scope/connectors/__init__.py +13 -0
- ioc_scope_api-1.0.0/scope/connectors/base.py +52 -0
- ioc_scope_api-1.0.0/scope/connectors/clickhouse.py +105 -0
- ioc_scope_api-1.0.0/scope/connectors/neo4j.py +220 -0
- ioc_scope_api-1.0.0/scope/connectors/sqlalchemy.py +131 -0
- ioc_scope_api-1.0.0/scope/core/config.py +530 -0
- ioc_scope_api-1.0.0/scope/core/exceptions.py +64 -0
- ioc_scope_api-1.0.0/scope/dependencies.py +164 -0
- ioc_scope_api-1.0.0/scope/health.py +10 -0
- ioc_scope_api-1.0.0/scope/interfaces/__init__.py +33 -0
- ioc_scope_api-1.0.0/scope/interfaces/data_provider.py +61 -0
- ioc_scope_api-1.0.0/scope/interfaces/integration_example.py +310 -0
- ioc_scope_api-1.0.0/scope/interfaces/kg_provider.py +91 -0
- ioc_scope_api-1.0.0/scope/interfaces/metrics_provider.py +92 -0
- ioc_scope_api-1.0.0/scope/interfaces/models.py +185 -0
- ioc_scope_api-1.0.0/scope/models/kg.py +48 -0
- ioc_scope_api-1.0.0/scope/models/live_topology.py +78 -0
- ioc_scope_api-1.0.0/scope/models/otel_traces.py +1595 -0
- ioc_scope_api-1.0.0/scope/providers/__init__.py +277 -0
- ioc_scope_api-1.0.0/scope/providers/_graph.py +59 -0
- ioc_scope_api-1.0.0/scope/providers/cognition_protocols.py +178 -0
- ioc_scope_api-1.0.0/scope/providers/kg.py +702 -0
- ioc_scope_api-1.0.0/scope/providers/kg_query_runner.py +109 -0
- ioc_scope_api-1.0.0/scope/providers/neo4j_mce.py +18 -0
- ioc_scope_api-1.0.0/scope/providers/scope_metrics.py +7 -0
- ioc_scope_api-1.0.0/scope/query_builders/__init__.py +14 -0
- ioc_scope_api-1.0.0/scope/query_builders/cognition_protocol_graph.py +191 -0
- ioc_scope_api-1.0.0/scope/query_builders/concepts.py +112 -0
- ioc_scope_api-1.0.0/scope/query_builders/dal.py +931 -0
- ioc_scope_api-1.0.0/scope/query_builders/failure_graph.py +102 -0
- ioc_scope_api-1.0.0/scope/query_builders/features.py +5 -0
- ioc_scope_api-1.0.0/scope/query_builders/kg.py +416 -0
- ioc_scope_api-1.0.0/scope/query_builders/labels.py +53 -0
- ioc_scope_api-1.0.0/scope/query_builders/live_topology.py +503 -0
- ioc_scope_api-1.0.0/scope/query_builders/metric_graph.py +196 -0
- ioc_scope_api-1.0.0/scope/query_builders/metrics.py +354 -0
- ioc_scope_api-1.0.0/scope/query_builders/semanticgroups.py +46 -0
- ioc_scope_api-1.0.0/scope/query_builders/sessions.py +208 -0
- ioc_scope_api-1.0.0/scope/query_builders/symbolic.py +615 -0
- ioc_scope_api-1.0.0/scope/query_builders/trajectory.py +76 -0
- ioc_scope_api-1.0.0/scope/query_builders/types.py +20 -0
- ioc_scope_api-1.0.0/scope/query_builders/ui.py +3278 -0
- ioc_scope_api-1.0.0/scope/query_builders/waste_estimation.py +221 -0
- ioc_scope_api-1.0.0/scope/repositories/__init__.py +28 -0
- ioc_scope_api-1.0.0/scope/repositories/clickhouse_otel_repository.py +135 -0
- ioc_scope_api-1.0.0/scope/repositories/otel_repository.py +97 -0
- ioc_scope_api-1.0.0/scope/repositories/sqlite_repository.py +215 -0
- ioc_scope_api-1.0.0/scope/scripts/__init__.py +2 -0
- ioc_scope_api-1.0.0/scope/scripts/seed.py +35 -0
- ioc_scope_api-1.0.0/scope/workarounds.py +38 -0
- ioc_scope_api-1.0.0/scripts/csv_to_sql.py +130 -0
- ioc_scope_api-1.0.0/scripts/test_metrics_sequence.sh +47 -0
- ioc_scope_api-1.0.0/scripts/test_metrics_single.sh +35 -0
- ioc_scope_api-1.0.0/tests/__init__.py +2 -0
- ioc_scope_api-1.0.0/tests/other/test_496_applications.py +726 -0
- ioc_scope_api-1.0.0/tests/other/test_application_charts_v2.py +163 -0
- ioc_scope_api-1.0.0/tests/other/test_caching_and_optimizations.py +707 -0
- ioc_scope_api-1.0.0/tests/other/test_endpoint_ui.py +799 -0
- ioc_scope_api-1.0.0/tests/other/test_endpoint_ui_ch.py +260 -0
- ioc_scope_api-1.0.0/tests/other/test_endpoint_ui_data_mocker.py +137 -0
- ioc_scope_api-1.0.0/tests/other/test_exceptions.py +206 -0
- ioc_scope_api-1.0.0/tests/other/test_functions.py +117 -0
- ioc_scope_api-1.0.0/tests/other/test_kg_query_builders.py +114 -0
- ioc_scope_api-1.0.0/tests/other/test_kg_retrieval.py +362 -0
- ioc_scope_api-1.0.0/tests/other/test_metrics_before_kg.py +185 -0
- ioc_scope_api-1.0.0/tests/other/test_metrics_endpoint_filtering.py +336 -0
- ioc_scope_api-1.0.0/tests/other/test_parallel_localhost_queries.py +90 -0
- ioc_scope_api-1.0.0/tests/other/test_semanticgroups.py +267 -0
- ioc_scope_api-1.0.0/tests/other/test_symbolic_api_live_db_context_extraction.py +478 -0
- ioc_scope_api-1.0.0/tests/other/test_with_local_dbs.py +207 -0
- ioc_scope_api-1.0.0/tests/test_agentic_protocols_metrics.py +99 -0
- ioc_scope_api-1.0.0/tests/test_application_charts.py +264 -0
- ioc_scope_api-1.0.0/tests/test_application_sessions.py +607 -0
- ioc_scope_api-1.0.0/tests/test_applications.py +163 -0
- ioc_scope_api-1.0.0/tests/test_caching.py +530 -0
- ioc_scope_api-1.0.0/tests/test_clickhouse_pool.py +117 -0
- ioc_scope_api-1.0.0/tests/test_cognition_protocol_report_provider.py +167 -0
- ioc_scope_api-1.0.0/tests/test_cognition_protocols.py +185 -0
- ioc_scope_api-1.0.0/tests/test_cognitive_observability.py +76 -0
- ioc_scope_api-1.0.0/tests/test_dal.py +279 -0
- ioc_scope_api-1.0.0/tests/test_dal_metric_queries.py +58 -0
- ioc_scope_api-1.0.0/tests/test_failure_reports.py +160 -0
- ioc_scope_api-1.0.0/tests/test_ingest_insights.py +58 -0
- ioc_scope_api-1.0.0/tests/test_kg.py +259 -0
- ioc_scope_api-1.0.0/tests/test_latent_space_extra.py +20 -0
- ioc_scope_api-1.0.0/tests/test_live_topology.py +360 -0
- ioc_scope_api-1.0.0/tests/test_local_client_lifecycle.py +124 -0
- ioc_scope_api-1.0.0/tests/test_mcev2.py +296 -0
- ioc_scope_api-1.0.0/tests/test_metric_evaluation_cost.py +313 -0
- ioc_scope_api-1.0.0/tests/test_metric_reader_queries.py +76 -0
- ioc_scope_api-1.0.0/tests/test_metrics.py +195 -0
- ioc_scope_api-1.0.0/tests/test_metrics_provider_persistence.py +200 -0
- ioc_scope_api-1.0.0/tests/test_metrics_provider_persistence_mocks.py +156 -0
- ioc_scope_api-1.0.0/tests/test_metrics_query_builders.py +101 -0
- ioc_scope_api-1.0.0/tests/test_neo4j_transient_errors.py +192 -0
- ioc_scope_api-1.0.0/tests/test_reasoning.py +187 -0
- ioc_scope_api-1.0.0/tests/test_session_span_links.py +50 -0
- ioc_scope_api-1.0.0/tests/test_sessions.py +179 -0
- ioc_scope_api-1.0.0/tests/test_structural_topology.py +138 -0
- ioc_scope_api-1.0.0/tests/test_symbolic_api.py +860 -0
- ioc_scope_api-1.0.0/tests/test_symbolic_api_mocks.py +817 -0
- ioc_scope_api-1.0.0/tests/test_trajectory_dal.py +276 -0
- ioc_scope_api-1.0.0/tests/test_waste_estimation.py +286 -0
- ioc_scope_api-1.0.0/workers/pyproject.toml +4 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# For our binary installer
|
|
2
|
+
data/deb-packages/*.deb
|
|
3
|
+
!data/deb-packages/git-lfs_3.7.1_amd64.deb
|
|
4
|
+
|
|
5
|
+
# Byte-compiled / optimized / DLL files
|
|
6
|
+
__pycache__/
|
|
7
|
+
*.py[cod]
|
|
8
|
+
*$py.class
|
|
9
|
+
draft
|
|
10
|
+
sandbox/
|
|
11
|
+
# C extensions
|
|
12
|
+
*.so
|
|
13
|
+
|
|
14
|
+
deploy/docker-compose.override.yml
|
|
15
|
+
|
|
16
|
+
# Distribution / packaging
|
|
17
|
+
.Python
|
|
18
|
+
build/
|
|
19
|
+
develop-eggs/
|
|
20
|
+
dist/
|
|
21
|
+
downloads/
|
|
22
|
+
eggs/
|
|
23
|
+
.eggs/
|
|
24
|
+
lib/
|
|
25
|
+
lib64/
|
|
26
|
+
parts/
|
|
27
|
+
sdist/
|
|
28
|
+
var/
|
|
29
|
+
wheels/
|
|
30
|
+
pip-wheel-metadata/
|
|
31
|
+
share/python-wheels/
|
|
32
|
+
*.egg-info/
|
|
33
|
+
.installed.cfg
|
|
34
|
+
*.egg
|
|
35
|
+
MANIFEST
|
|
36
|
+
|
|
37
|
+
# PyInstaller
|
|
38
|
+
# Usually these files are written by a python script from a template
|
|
39
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
40
|
+
*.manifest
|
|
41
|
+
*.spec
|
|
42
|
+
|
|
43
|
+
# Installer logs
|
|
44
|
+
pip-log.txt
|
|
45
|
+
pip-delete-this-directory.txt
|
|
46
|
+
|
|
47
|
+
# Unit test / coverage reports
|
|
48
|
+
htmlcov/
|
|
49
|
+
.tox/
|
|
50
|
+
.nox/
|
|
51
|
+
.coverage
|
|
52
|
+
.coverage.*
|
|
53
|
+
.cache
|
|
54
|
+
nosetests.xml
|
|
55
|
+
coverage.xml
|
|
56
|
+
*.cover
|
|
57
|
+
*.py,cover
|
|
58
|
+
.hypothesis/
|
|
59
|
+
.pytest_cache/
|
|
60
|
+
|
|
61
|
+
# Translations
|
|
62
|
+
*.mo
|
|
63
|
+
*.pot
|
|
64
|
+
|
|
65
|
+
# Django stuff:
|
|
66
|
+
*.log
|
|
67
|
+
local_settings.py
|
|
68
|
+
db.sqlite3
|
|
69
|
+
db.sqlite3-journal
|
|
70
|
+
|
|
71
|
+
# Flask stuff:
|
|
72
|
+
instance/
|
|
73
|
+
.webassets-cache
|
|
74
|
+
|
|
75
|
+
# Scrapy stuff:
|
|
76
|
+
.scrapy
|
|
77
|
+
|
|
78
|
+
# Sphinx documentation
|
|
79
|
+
docs/_build/
|
|
80
|
+
|
|
81
|
+
# PyBuilder
|
|
82
|
+
target/
|
|
83
|
+
|
|
84
|
+
# Jupyter Notebook
|
|
85
|
+
.ipynb_checkpoints
|
|
86
|
+
|
|
87
|
+
# IPython
|
|
88
|
+
profile_default/
|
|
89
|
+
ipython_config.py
|
|
90
|
+
|
|
91
|
+
# pyenv
|
|
92
|
+
.python-version
|
|
93
|
+
|
|
94
|
+
# pipenv
|
|
95
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
96
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
97
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
98
|
+
# install all needed dependencies.
|
|
99
|
+
#Pipfile.lock
|
|
100
|
+
|
|
101
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
102
|
+
__pypackages__/
|
|
103
|
+
|
|
104
|
+
# Celery stuff
|
|
105
|
+
celerybeat-schedule
|
|
106
|
+
celerybeat.pid
|
|
107
|
+
|
|
108
|
+
# SageMath parsed files
|
|
109
|
+
*.sage.py
|
|
110
|
+
|
|
111
|
+
# Environments
|
|
112
|
+
.env
|
|
113
|
+
.venv
|
|
114
|
+
env/
|
|
115
|
+
venv/
|
|
116
|
+
ENV/
|
|
117
|
+
env.bak/
|
|
118
|
+
venv.bak/
|
|
119
|
+
|
|
120
|
+
# Spyder project settings
|
|
121
|
+
.spyderproject
|
|
122
|
+
.spyproject
|
|
123
|
+
|
|
124
|
+
# Rope project settings
|
|
125
|
+
.ropeproject
|
|
126
|
+
|
|
127
|
+
# mkdocs documentation
|
|
128
|
+
/site
|
|
129
|
+
|
|
130
|
+
# mypy
|
|
131
|
+
.mypy_cache/
|
|
132
|
+
.dmypy.json
|
|
133
|
+
dmypy.json
|
|
134
|
+
|
|
135
|
+
# Pyre type checker
|
|
136
|
+
.pyre/
|
|
137
|
+
|
|
138
|
+
# Mac files
|
|
139
|
+
.DS_Store
|
|
140
|
+
|
|
141
|
+
# Environment variables
|
|
142
|
+
.env
|
|
143
|
+
|
|
144
|
+
# sqlite database files
|
|
145
|
+
*.db
|
|
146
|
+
*.db-shm
|
|
147
|
+
*.db-wal
|
|
148
|
+
|
|
149
|
+
# PNG files
|
|
150
|
+
*.png
|
|
151
|
+
|
|
152
|
+
demo/
|
|
153
|
+
|
|
154
|
+
.ruff_cache
|
|
155
|
+
|
|
156
|
+
.vscode/
|
|
157
|
+
|
|
158
|
+
output/
|
|
159
|
+
|
|
160
|
+
.terraform.lock.hcl
|
|
161
|
+
.terraform/
|
|
162
|
+
foo.sh
|
|
163
|
+
tfplan
|
|
164
|
+
tfplan.txt
|
|
165
|
+
tfplan.json
|
|
166
|
+
terraform_output.json
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
# IntelliJ / PyCharm
|
|
170
|
+
.idea
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
*.txt
|
|
174
|
+
|
|
175
|
+
.dockerconfigjson
|
|
176
|
+
|
|
177
|
+
app/src/bedrock_agent/deploy
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
.deepeval/
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Copyright (c) 2026 Cisco Systems, Inc. and its affiliates
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
FROM python:3.13-slim-trixie AS builder
|
|
4
|
+
|
|
5
|
+
ENV PYTHONUNBUFFERED=1
|
|
6
|
+
ENV PYTHONDONTWRITEBYTECODE=1
|
|
7
|
+
|
|
8
|
+
COPY --from=ghcr.io/astral-sh/uv:0.5.26 /uv /bin/uv
|
|
9
|
+
|
|
10
|
+
ENV UV_LINK_MODE=copy \
|
|
11
|
+
UV_COMPILE_BYTECODE=1 \
|
|
12
|
+
UV_PYTHON_DOWNLOADS=never \
|
|
13
|
+
UV_PYTHON=python3.13 \
|
|
14
|
+
UV_PROJECT_ENVIRONMENT=/app
|
|
15
|
+
|
|
16
|
+
WORKDIR /src
|
|
17
|
+
|
|
18
|
+
# Copy workspace root files and project metadata for dependency resolution.
|
|
19
|
+
# Separate layer for caching: dependency resolution is independent of source code changes.
|
|
20
|
+
COPY pyproject.toml /src/pyproject.toml
|
|
21
|
+
COPY uv.lock /src/uv.lock
|
|
22
|
+
COPY uv.lock /src/api/uv.lock
|
|
23
|
+
COPY api/pyproject.toml /src/api/pyproject.toml
|
|
24
|
+
COPY --from=ontology . /ontology
|
|
25
|
+
|
|
26
|
+
# Install dependencies without installing source code yet.
|
|
27
|
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
28
|
+
cd /src && uv sync --frozen --no-dev --no-install-project --no-install-workspace --no-sources --extra latent-space --extra clickhouse-sqlalchemy --project /src/api
|
|
29
|
+
|
|
30
|
+
# Copy the API source code.
|
|
31
|
+
COPY api /src/api
|
|
32
|
+
|
|
33
|
+
# Install the ioc-scope-api package
|
|
34
|
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
35
|
+
cd /src && uv sync --frozen --no-dev --no-editable --extra latent-space --extra clickhouse-sqlalchemy --project /src/api
|
|
36
|
+
|
|
37
|
+
FROM python:3.13-slim-trixie AS runner
|
|
38
|
+
|
|
39
|
+
RUN useradd -m user
|
|
40
|
+
|
|
41
|
+
# Copy venv from builder with just the dependencies we need + our package
|
|
42
|
+
COPY --from=builder --chown=user:user /app /app
|
|
43
|
+
|
|
44
|
+
USER user
|
|
45
|
+
|
|
46
|
+
EXPOSE 8000
|
|
47
|
+
|
|
48
|
+
CMD ["/app/bin/dev"]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Copyright (c) 2026 Cisco Systems, Inc. and its affiliates
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
.PHONY: test-rest-api
|
|
4
|
+
|
|
5
|
+
test-rest-api:
|
|
6
|
+
@.venv/bin/uvicorn main:app --reload & \
|
|
7
|
+
sleep 3 && \
|
|
8
|
+
echo "--- Applications (SQLite) ---" && \
|
|
9
|
+
curl -s http://127.0.0.1:8000/applications/001 | .venv/bin/python -m json.tool && \
|
|
10
|
+
echo "--- Users (ClickHouse) ---" && \
|
|
11
|
+
curl -s http://127.0.0.1:8000/users/001 | .venv/bin/python -m json.tool && \
|
|
12
|
+
echo "--- Favorites (PostgreSQL) ---" && \
|
|
13
|
+
curl -s http://127.0.0.1:8000/users/001/favorites | .venv/bin/python -m json.tool; \
|
|
14
|
+
kill %1 2>/dev/null
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ioc-scope-api
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: SCOPE backend API service
|
|
5
|
+
Author-email: Outshift Open <oss-github@cisco.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Requires-Python: >=3.13
|
|
8
|
+
Requires-Dist: clickhouse-connect>=0.11.0
|
|
9
|
+
Requires-Dist: fastapi>=0.129.0
|
|
10
|
+
Requires-Dist: ioc-scope-ontology[models,verify]>=1.1.0
|
|
11
|
+
Requires-Dist: neo4j>=6.1.0
|
|
12
|
+
Requires-Dist: numpy>=2.3.5
|
|
13
|
+
Requires-Dist: packaging>=26.0
|
|
14
|
+
Requires-Dist: pydantic-settings>=2.13.1
|
|
15
|
+
Requires-Dist: python-dotenv>=1.2.1
|
|
16
|
+
Requires-Dist: redis>=5.0.0
|
|
17
|
+
Requires-Dist: requests>=2.32.5
|
|
18
|
+
Requires-Dist: ruff<=0.15.22
|
|
19
|
+
Requires-Dist: sqlalchemy>=2.0.46
|
|
20
|
+
Requires-Dist: uvicorn>=0.41.0
|
|
21
|
+
Provides-Extra: clickhouse-sqlalchemy
|
|
22
|
+
Requires-Dist: clickhouse-sqlalchemy>=0.3.2; extra == 'clickhouse-sqlalchemy'
|
|
23
|
+
Provides-Extra: latent-space
|
|
24
|
+
Requires-Dist: numba>=0.60.0; extra == 'latent-space'
|
|
25
|
+
Requires-Dist: umap-learn>=0.5.7; extra == 'latent-space'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# SCOPE API
|
|
29
|
+
|
|
30
|
+
Unified DB access layer across SCOPE. It consolidates the fragmented data access patterns currently spread across scope-backend, DAL, and workflow components into one single library and provides an optional REST API, for use by the downstream components.
|
|
31
|
+
|
|
32
|
+
## Tech stack
|
|
33
|
+
|
|
34
|
+
- **Python 3.13+**
|
|
35
|
+
- **SQLAlchemy** — ORM / database toolkit (SQLite & ClickHouse backends)
|
|
36
|
+
- **clickhouse-connect** — native ClickHouse driver
|
|
37
|
+
- **FastAPI** + **Uvicorn** — async HTTP server
|
|
38
|
+
|
|
39
|
+
## Quick start
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# 1. Create a virtual environment & install dependencies
|
|
43
|
+
uv venv
|
|
44
|
+
source .venv/bin/activate
|
|
45
|
+
uv sync
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
# 2. Run the server
|
|
49
|
+
```bash
|
|
50
|
+
export CLICKHOUSE_HOST=localhost
|
|
51
|
+
export CLICKHOUSE_PORT=8123
|
|
52
|
+
export CLICKHOUSE_USERNAME=scopeclickhouseuser
|
|
53
|
+
export CLICKHOUSE_PASSWORD=scopeclickhousepassword
|
|
54
|
+
export CLICKHOUSE_DATABASE=scope
|
|
55
|
+
uv run dev
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The API will be available at **http://127.0.0.1:8000**.
|
|
59
|
+
|
|
60
|
+
OpenAPI specification docs are available at **http://127.0.0.1:8000/docs**.
|
|
61
|
+
|
|
62
|
+
## Running tests
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Recreate a dedicated test environment from the project metadata
|
|
66
|
+
uv venv .venv_tests
|
|
67
|
+
source .venv_tests/bin/activate
|
|
68
|
+
uv sync --active --dev
|
|
69
|
+
|
|
70
|
+
# Run the test suites
|
|
71
|
+
python -m pytest tests/ -v
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The `uv sync --active --dev` step installs both the main project dependencies
|
|
75
|
+
and the test-only dependencies declared in `pyproject.toml`, including vendored
|
|
76
|
+
wheel dependencies such as `mce-core`, `mce-provider-native`, and
|
|
77
|
+
`mce-provider-sdk`.
|
|
78
|
+
|
|
79
|
+
No additional `uv pip install` commands are required for metric compute in local
|
|
80
|
+
dev or CI when syncing with `--group dev`.
|
|
81
|
+
|
|
82
|
+
### Vendored wheel maintenance (important for Docker builds)
|
|
83
|
+
|
|
84
|
+
The API image build uses Docker `context: api`, so `uv.lock` cannot contain
|
|
85
|
+
sources outside that directory (for example `../mce/...`). Keep
|
|
86
|
+
`[tool.uv.sources]` and `api/uv.lock` pointing to `api/vendor/*.whl` paths.
|
|
87
|
+
|
|
88
|
+
When updating `mce-core` or MCE providers:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# From repo root
|
|
92
|
+
uv build mce/mce-core
|
|
93
|
+
uv build mce/mce-provider-native
|
|
94
|
+
uv build mce/mce-provider-sdk
|
|
95
|
+
|
|
96
|
+
cp mce/dist/mce_core-2.0.0rc1-py3-none-any.whl api/vendor/
|
|
97
|
+
cp mce/dist/mce_provider_native-0.1.0-py3-none-any.whl api/vendor/
|
|
98
|
+
cp mce/dist/mce_provider_sdk-0.1.0-py3-none-any.whl api/vendor/
|
|
99
|
+
|
|
100
|
+
uv lock --project ./api
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Docker
|
|
104
|
+
|
|
105
|
+
### Build the image
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
docker build -t scope-api -f Dockerfile .
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
or use `docker compose` to build as part of the full stack:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
docker compose -f deploy/docker-compose.yml --build scope-api
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Run the container standalone
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
docker run --rm -p 8000:8000 \
|
|
121
|
+
-e CLICKHOUSE_HOST=host.docker.internal \
|
|
122
|
+
-e CLICKHOUSE_PORT=8123 \
|
|
123
|
+
-e CLICKHOUSE_USERNAME=scopeclickhouseuser \
|
|
124
|
+
-e CLICKHOUSE_PASSWORD=scopeclickhousepassword \
|
|
125
|
+
-e CLICKHOUSE_DATABASE=default \
|
|
126
|
+
scope-api
|
|
127
|
+
```
|
|
128
|
+
The init script ([data/clickhouse/otel_traces.sql](data/clickhouse/otel_traces.sql)) runs automatically on first startup, creating the `scope` database.
|
|
129
|
+
|
|
130
|
+
| Service | URL |
|
|
131
|
+
|---------|-----|
|
|
132
|
+
| SCOPE API | `http://localhost:8000` |
|
|
133
|
+
| ClickHouse HTTP | `http://localhost:8123` |
|
|
134
|
+
| ClickHouse TCP | `localhost:9000` |
|
|
135
|
+
|
|
136
|
+
## Test HTTP REST API
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
make test-rest-api
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Using as a Python library
|
|
143
|
+
|
|
144
|
+
Besides running as a REST server, `scope-api` can be imported directly into any Python project as a library.
|
|
145
|
+
|
|
146
|
+
### Quick example
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from scope import LocalClient
|
|
150
|
+
|
|
151
|
+
with LocalClient() as client:
|
|
152
|
+
apps = client.get_application_names()
|
|
153
|
+
sessions = client.get_sessions(app_name="my-app", limit=10)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Specifying database credentials
|
|
157
|
+
|
|
158
|
+
`LocalClient` accepts an optional `db` argument — a **Connector** instance that
|
|
159
|
+
you configure with explicit credentials. When `db` is omitted, the backend is
|
|
160
|
+
chosen automatically through the `SCOPE_LOCAL` environment variable (see
|
|
161
|
+
[Environment-variable mode](#environment-variable-mode) below).
|
|
162
|
+
|
|
163
|
+
#### Option A — ClickHouse (via `clickhouse-connect`)
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
from scope import LocalClient
|
|
167
|
+
from scope.connectors.clickhouse import ClickHouseConnector
|
|
168
|
+
|
|
169
|
+
db = ClickHouseConnector(
|
|
170
|
+
host="clickhouse.example.com",
|
|
171
|
+
port=8123,
|
|
172
|
+
username="scope_user",
|
|
173
|
+
password="s3cret",
|
|
174
|
+
database="scope",
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
with LocalClient(db=db) as client:
|
|
178
|
+
apps = client.get_applications()
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
#### Option B — PostgreSQL (via SQLAlchemy)
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
from scope import LocalClient
|
|
185
|
+
from scope.connectors.sqlalchemy import SQLAlchemyConnector
|
|
186
|
+
|
|
187
|
+
# PostgreSQL
|
|
188
|
+
db = SQLAlchemyConnector(url="postgresql://user:pass@host:5432/scope")
|
|
189
|
+
|
|
190
|
+
with LocalClient(db=db) as client:
|
|
191
|
+
sessions = client.list_sessions(limit=20)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
#### Option C — Neo4j (for KG, metrics, and concepts operations)
|
|
195
|
+
|
|
196
|
+
KG, metrics, and concepts methods require a Neo4j-backed connector:
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
from scope import LocalClient
|
|
200
|
+
from scope.connectors.neo4j import Neo4JConnector
|
|
201
|
+
|
|
202
|
+
db = Neo4JConnector(
|
|
203
|
+
host="neo4j.example.com",
|
|
204
|
+
port=7687,
|
|
205
|
+
username="neo4j",
|
|
206
|
+
password="s3cret",
|
|
207
|
+
database="neo4j",
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
with LocalClient(db=db) as client:
|
|
211
|
+
state = client.get_state_by_session_id("session-abc")
|
|
212
|
+
metrics = client.get_session_metrics("session-abc", hops=2)
|
|
213
|
+
concepts = client.get_app_concepts("my-app")
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### Environment-variable mode
|
|
217
|
+
|
|
218
|
+
When you create `LocalClient()` **without** a `db` argument, the backend is
|
|
219
|
+
selected by the `SCOPE_LOCAL` environment variable:
|
|
220
|
+
|
|
221
|
+
| `SCOPE_LOCAL` | Backend | Credentials read from |
|
|
222
|
+
|----------------------------|------------|-----------------------------------|
|
|
223
|
+
| `true` / `1` / `yes` *(default)* | SQLite | Uses `scope.db` in the working directory |
|
|
224
|
+
| Any other value | ClickHouse | `CLICKHOUSE_HOST`, `CLICKHOUSE_PORT`, `CLICKHOUSE_USERNAME`, `CLICKHOUSE_PASSWORD`, `CLICKHOUSE_DATABASE` |
|
|
225
|
+
|
|
226
|
+
Neo4j settings (used by the REST server's dependency injection) are read from:
|
|
227
|
+
|
|
228
|
+
| Variable | Default |
|
|
229
|
+
|--------------------|-------------|
|
|
230
|
+
| `NEO4J_HOST` | `localhost` |
|
|
231
|
+
| `NEO4J_PORT` | `7687` |
|
|
232
|
+
| `NEO4J_USERNAME` | `neo4j` |
|
|
233
|
+
| `NEO4J_PASSWORD` | *(empty)* |
|
|
234
|
+
| `NEO4J_DATABASE` | `neo4j` |
|
|
235
|
+
|
|
236
|
+
Example:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
export SCOPE_LOCAL=false
|
|
240
|
+
export CLICKHOUSE_HOST=clickhouse.example.com
|
|
241
|
+
export CLICKHOUSE_PORT=8123
|
|
242
|
+
export CLICKHOUSE_USERNAME=scope_user
|
|
243
|
+
export CLICKHOUSE_PASSWORD=s3cret
|
|
244
|
+
export CLICKHOUSE_DATABASE=scope
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
```python
|
|
248
|
+
from scope import LocalClient
|
|
249
|
+
|
|
250
|
+
# Automatically connects to the ClickHouse instance above
|
|
251
|
+
client = LocalClient()
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Available client methods
|
|
255
|
+
|
|
256
|
+
| Domain | Method | Description |
|
|
257
|
+
|--------|--------|-------------|
|
|
258
|
+
| **Applications** | `get_application_names(...)` | List known application IDs |
|
|
259
|
+
| | `get_applications(...)` | Applications with agents, LLMs, cost, perf |
|
|
260
|
+
| | `get_application_details(...)` | Application-level monitoring data |
|
|
261
|
+
| | `get_application_agents(...)` | Per-agent monitoring for an app |
|
|
262
|
+
| **Sessions** | `get_sessions(...)` | Session/trace summaries |
|
|
263
|
+
| | `list_sessions(...)` | Flat session listing |
|
|
264
|
+
| | `get_session_agents(...)` | Agents within a session |
|
|
265
|
+
| | `get_session_agent_details(...)` | Detailed agent info in a session |
|
|
266
|
+
| | `_get_session_timeline(...)` | Waterfall span tree |
|
|
267
|
+
| | `get_session_spans(...)` | Span attributes for session(s) |
|
|
268
|
+
| **Spans** | `get_spans(...)` | Single span details |
|
|
269
|
+
| **KG** | `get_state_by_session_id(...)` | Session state from knowledge graph |
|
|
270
|
+
| | `get_embedding_by_session_id(...)` | Embedding vector for a session |
|
|
271
|
+
| | `get_neighbors(...)` | Similar sessions by embedding distance |
|
|
272
|
+
| **Metrics** | `get_session_metrics(...)` | KG metrics for a session |
|
|
273
|
+
| | `get_span_metrics(...)` | KG metrics for a span |
|
|
274
|
+
| **Concepts** | `get_app_concepts(...)` | Neurosymbolic concepts for an app |
|
|
275
|
+
| | `get_span_concepts(...)` | Concepts scoped to a specific span |
|
|
276
|
+
|
|
277
|
+
### Type hints & return types
|
|
278
|
+
|
|
279
|
+
All methods return **Pydantic models** (e.g. `TracesResponse`,
|
|
280
|
+
`ApplicationsResponse`, `SpanDetailsResponse`) defined in
|
|
281
|
+
`scope.models.otel_traces`. Results are fully typed and serializable:
|
|
282
|
+
|
|
283
|
+
```python
|
|
284
|
+
from scope import LocalClient
|
|
285
|
+
|
|
286
|
+
with LocalClient() as client:
|
|
287
|
+
resp = client.get_applications()
|
|
288
|
+
for app in resp.applications:
|
|
289
|
+
print(app.applicationName, app.cost)
|
|
290
|
+
|
|
291
|
+
# Serialize to dict / JSON
|
|
292
|
+
print(resp.model_dump_json(indent=2))
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
For dependency injection or testing, type-hint against the abstract base class:
|
|
296
|
+
|
|
297
|
+
```python
|
|
298
|
+
from scope import SCOPEAPIClient, LocalClient
|
|
299
|
+
|
|
300
|
+
def analyze(client: SCOPEAPIClient):
|
|
301
|
+
...
|
|
302
|
+
|
|
303
|
+
analyze(LocalClient())
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
|