londonaicentre-mesa-runner 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.
- londonaicentre_mesa_runner-1.0.0/PKG-INFO +141 -0
- londonaicentre_mesa_runner-1.0.0/README.md +126 -0
- londonaicentre_mesa_runner-1.0.0/pyproject.toml +61 -0
- londonaicentre_mesa_runner-1.0.0/setup.cfg +4 -0
- londonaicentre_mesa_runner-1.0.0/src/londonaicentre_mesa_runner.egg-info/PKG-INFO +141 -0
- londonaicentre_mesa_runner-1.0.0/src/londonaicentre_mesa_runner.egg-info/SOURCES.txt +34 -0
- londonaicentre_mesa_runner-1.0.0/src/londonaicentre_mesa_runner.egg-info/dependency_links.txt +1 -0
- londonaicentre_mesa_runner-1.0.0/src/londonaicentre_mesa_runner.egg-info/entry_points.txt +2 -0
- londonaicentre_mesa_runner-1.0.0/src/londonaicentre_mesa_runner.egg-info/requires.txt +8 -0
- londonaicentre_mesa_runner-1.0.0/src/londonaicentre_mesa_runner.egg-info/top_level.txt +1 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/__init__.py +0 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/adapters/__init__.py +47 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/adapters/dry_run.py +69 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/adapters/filesystem.py +176 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/adapters/io_schemas.py +66 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/adapters/s3.py +192 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/adapters/snowflake.py +198 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/adapters/storage_base.py +36 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/config/__init__.py +12 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/config/config_base.py +154 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/config/filesystem.py +16 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/config/s3.py +49 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/config/snowflake.py +46 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/inferrer.py +246 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/log_filters.py +77 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/main.py +128 -0
- londonaicentre_mesa_runner-1.0.0/src/mesa_runner/runner.py +199 -0
- londonaicentre_mesa_runner-1.0.0/tests/test_adapter_dry_run.py +133 -0
- londonaicentre_mesa_runner-1.0.0/tests/test_adapter_filesystem.py +448 -0
- londonaicentre_mesa_runner-1.0.0/tests/test_adapter_s3.py +482 -0
- londonaicentre_mesa_runner-1.0.0/tests/test_adapters.py +185 -0
- londonaicentre_mesa_runner-1.0.0/tests/test_config.py +76 -0
- londonaicentre_mesa_runner-1.0.0/tests/test_inferrer.py +19 -0
- londonaicentre_mesa_runner-1.0.0/tests/test_log_filters.py +244 -0
- londonaicentre_mesa_runner-1.0.0/tests/test_runtime.py +377 -0
- londonaicentre_mesa_runner-1.0.0/tests/test_snowflake_wrapper.py +168 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: londonaicentre-mesa-runner
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A stateless runner / deployment system for MESA models
|
|
5
|
+
Requires-Python: >=3.13
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: boto3>=1.42.43
|
|
8
|
+
Requires-Dist: duckdb>=1.4.4
|
|
9
|
+
Requires-Dist: londonaicentre-oncoschema>=2.0.1
|
|
10
|
+
Requires-Dist: pandas>=2.3.3
|
|
11
|
+
Requires-Dist: pydantic>=2.12.5
|
|
12
|
+
Requires-Dist: pydantic-settings[yaml]>=2.12.0
|
|
13
|
+
Requires-Dist: snowflake-core>=1.11.0
|
|
14
|
+
Requires-Dist: snowflake-snowpark-python>=1.45.0
|
|
15
|
+
|
|
16
|
+
# MESA Runner
|
|
17
|
+
|
|
18
|
+
A stateless runner for deploying MESA registered models onto GSTT Infrastructure. It syncs models from S3, reads unprocessed documents from Snowflake, runs inference, and writes results back.
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- Python 3.13+
|
|
23
|
+
- [uv](https://github.com/astral-sh/uv) package manager
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
### Remote Inference (Default)
|
|
28
|
+
|
|
29
|
+
For remote inference via OpenAI-compatible endpoints:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
uv sync
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Offline Inference (Optional)
|
|
36
|
+
|
|
37
|
+
For local GPU inference with vLLM, install the optional dependency:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
uv sync --group vllm-offline
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
Create a `config.yaml` file (see example below):
|
|
46
|
+
|
|
47
|
+
### Remote Inference Example
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
my_source:
|
|
51
|
+
model_s3_uri: "s3://aicentre-nlpteam-mesa-build/models/oncoqwen/oncoqwen_1/"
|
|
52
|
+
|
|
53
|
+
inference:
|
|
54
|
+
openai_endpoint: "http://localhost:5000/v1"
|
|
55
|
+
|
|
56
|
+
storage:
|
|
57
|
+
type: snowflake
|
|
58
|
+
source_database: "str"
|
|
59
|
+
source_schema: "str"
|
|
60
|
+
source_table: "str"
|
|
61
|
+
|
|
62
|
+
sink_database: "str"
|
|
63
|
+
sink_schema: "str"
|
|
64
|
+
sink_table: "str"
|
|
65
|
+
|
|
66
|
+
connection_params:
|
|
67
|
+
account: "str"
|
|
68
|
+
user: "str"
|
|
69
|
+
role: "str"
|
|
70
|
+
password: "str"
|
|
71
|
+
warehouse: "str"
|
|
72
|
+
database: "str"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Offline Inference Example
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
my_source:
|
|
79
|
+
model_s3_uri: "s3://aicentre-nlpteam-mesa-build/models/oncoqwen/oncoqwen_1/"
|
|
80
|
+
|
|
81
|
+
inference:
|
|
82
|
+
max_model_len: 18000
|
|
83
|
+
|
|
84
|
+
storage:
|
|
85
|
+
type: snowflake
|
|
86
|
+
source_database: "str"
|
|
87
|
+
source_schema: "str"
|
|
88
|
+
source_table: "str"
|
|
89
|
+
|
|
90
|
+
sink_database: "str"
|
|
91
|
+
sink_schema: "str"
|
|
92
|
+
sink_table: "str"
|
|
93
|
+
|
|
94
|
+
connection_params:
|
|
95
|
+
account: "str"
|
|
96
|
+
user: "str"
|
|
97
|
+
role: "str"
|
|
98
|
+
password: "str"
|
|
99
|
+
warehouse: "str"
|
|
100
|
+
database: "str"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Usage
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Run with default config.yaml
|
|
107
|
+
mesa_runner
|
|
108
|
+
|
|
109
|
+
# Or specify a config file
|
|
110
|
+
mesa_runner --config /path/to/config.yaml
|
|
111
|
+
|
|
112
|
+
# Dry run mode (uses dummy data, does not read or write real data)
|
|
113
|
+
mesa_runner --dry-run
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The dry run mode is useful for testing the runner without accessing real data sources or sinks. It generates 5 dummy documents by default and logs all write operations instead of executing them.
|
|
117
|
+
|
|
118
|
+
## Docker
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Remote inference (default)
|
|
122
|
+
docker build -t mesa-runner .
|
|
123
|
+
docker run mesa-runner
|
|
124
|
+
|
|
125
|
+
# Offline inference (includes vLLM)
|
|
126
|
+
docker build --target offline -t mesa-runner:offline .
|
|
127
|
+
docker run --gpus all mesa-runner:offline
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Development
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Run linting and tests
|
|
134
|
+
make test
|
|
135
|
+
|
|
136
|
+
# Auto-fix linting issues
|
|
137
|
+
make fix
|
|
138
|
+
|
|
139
|
+
# Run tests with coverage
|
|
140
|
+
make cov
|
|
141
|
+
```
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# MESA Runner
|
|
2
|
+
|
|
3
|
+
A stateless runner for deploying MESA registered models onto GSTT Infrastructure. It syncs models from S3, reads unprocessed documents from Snowflake, runs inference, and writes results back.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Python 3.13+
|
|
8
|
+
- [uv](https://github.com/astral-sh/uv) package manager
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
### Remote Inference (Default)
|
|
13
|
+
|
|
14
|
+
For remote inference via OpenAI-compatible endpoints:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
uv sync
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Offline Inference (Optional)
|
|
21
|
+
|
|
22
|
+
For local GPU inference with vLLM, install the optional dependency:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
uv sync --group vllm-offline
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Configuration
|
|
29
|
+
|
|
30
|
+
Create a `config.yaml` file (see example below):
|
|
31
|
+
|
|
32
|
+
### Remote Inference Example
|
|
33
|
+
|
|
34
|
+
```yaml
|
|
35
|
+
my_source:
|
|
36
|
+
model_s3_uri: "s3://aicentre-nlpteam-mesa-build/models/oncoqwen/oncoqwen_1/"
|
|
37
|
+
|
|
38
|
+
inference:
|
|
39
|
+
openai_endpoint: "http://localhost:5000/v1"
|
|
40
|
+
|
|
41
|
+
storage:
|
|
42
|
+
type: snowflake
|
|
43
|
+
source_database: "str"
|
|
44
|
+
source_schema: "str"
|
|
45
|
+
source_table: "str"
|
|
46
|
+
|
|
47
|
+
sink_database: "str"
|
|
48
|
+
sink_schema: "str"
|
|
49
|
+
sink_table: "str"
|
|
50
|
+
|
|
51
|
+
connection_params:
|
|
52
|
+
account: "str"
|
|
53
|
+
user: "str"
|
|
54
|
+
role: "str"
|
|
55
|
+
password: "str"
|
|
56
|
+
warehouse: "str"
|
|
57
|
+
database: "str"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Offline Inference Example
|
|
61
|
+
|
|
62
|
+
```yaml
|
|
63
|
+
my_source:
|
|
64
|
+
model_s3_uri: "s3://aicentre-nlpteam-mesa-build/models/oncoqwen/oncoqwen_1/"
|
|
65
|
+
|
|
66
|
+
inference:
|
|
67
|
+
max_model_len: 18000
|
|
68
|
+
|
|
69
|
+
storage:
|
|
70
|
+
type: snowflake
|
|
71
|
+
source_database: "str"
|
|
72
|
+
source_schema: "str"
|
|
73
|
+
source_table: "str"
|
|
74
|
+
|
|
75
|
+
sink_database: "str"
|
|
76
|
+
sink_schema: "str"
|
|
77
|
+
sink_table: "str"
|
|
78
|
+
|
|
79
|
+
connection_params:
|
|
80
|
+
account: "str"
|
|
81
|
+
user: "str"
|
|
82
|
+
role: "str"
|
|
83
|
+
password: "str"
|
|
84
|
+
warehouse: "str"
|
|
85
|
+
database: "str"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Usage
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Run with default config.yaml
|
|
92
|
+
mesa_runner
|
|
93
|
+
|
|
94
|
+
# Or specify a config file
|
|
95
|
+
mesa_runner --config /path/to/config.yaml
|
|
96
|
+
|
|
97
|
+
# Dry run mode (uses dummy data, does not read or write real data)
|
|
98
|
+
mesa_runner --dry-run
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The dry run mode is useful for testing the runner without accessing real data sources or sinks. It generates 5 dummy documents by default and logs all write operations instead of executing them.
|
|
102
|
+
|
|
103
|
+
## Docker
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Remote inference (default)
|
|
107
|
+
docker build -t mesa-runner .
|
|
108
|
+
docker run mesa-runner
|
|
109
|
+
|
|
110
|
+
# Offline inference (includes vLLM)
|
|
111
|
+
docker build --target offline -t mesa-runner:offline .
|
|
112
|
+
docker run --gpus all mesa-runner:offline
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Development
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Run linting and tests
|
|
119
|
+
make test
|
|
120
|
+
|
|
121
|
+
# Auto-fix linting issues
|
|
122
|
+
make fix
|
|
123
|
+
|
|
124
|
+
# Run tests with coverage
|
|
125
|
+
make cov
|
|
126
|
+
```
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "londonaicentre-mesa-runner"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "A stateless runner / deployment system for MESA models"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"boto3>=1.42.43",
|
|
9
|
+
"duckdb>=1.4.4",
|
|
10
|
+
"londonaicentre-oncoschema>=2.0.1",
|
|
11
|
+
"pandas>=2.3.3",
|
|
12
|
+
"pydantic>=2.12.5",
|
|
13
|
+
"pydantic-settings[yaml]>=2.12.0",
|
|
14
|
+
"snowflake-core>=1.11.0",
|
|
15
|
+
"snowflake-snowpark-python>=1.45.0",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
[dependency-groups]
|
|
20
|
+
dev = [
|
|
21
|
+
"fastapi>=0.128.5",
|
|
22
|
+
"pytest>=9.0.2",
|
|
23
|
+
"pytest-asyncio>=1.3.0",
|
|
24
|
+
"pytest-cov>=7.0.0",
|
|
25
|
+
"pytest-mock>=3.15.1",
|
|
26
|
+
"ruff>=0.15.0",
|
|
27
|
+
"snowflake-snowpark-python[localtest]>=1.45.0",
|
|
28
|
+
"tenacity>=9.1.4",
|
|
29
|
+
"ty>=0.0.15",
|
|
30
|
+
"types-boto3[s3]>=1.42.44",
|
|
31
|
+
]
|
|
32
|
+
vllm-offline = [
|
|
33
|
+
"londonaicentre-mesa-local>=2.2.0",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[tool.uv]
|
|
37
|
+
package = true
|
|
38
|
+
|
|
39
|
+
[project.scripts]
|
|
40
|
+
mesa_runner = "mesa_runnner.main:main"
|
|
41
|
+
|
|
42
|
+
[tool.ruff]
|
|
43
|
+
line-length = 100
|
|
44
|
+
|
|
45
|
+
[tool.ruff.lint]
|
|
46
|
+
select = [
|
|
47
|
+
"E", # pycodestyle: bad formatting
|
|
48
|
+
"W", # pycodestyle: warnings
|
|
49
|
+
"F", # pyflakes: common errors
|
|
50
|
+
"I", # isort: handles badly setup imports, and orders
|
|
51
|
+
"B", # flake8-bugbear: common bugs/footguns
|
|
52
|
+
"C90", # mccabe cyclomatic complexity: for badly nested conditional statements that makes logic hard to follow
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
[tool.pytest.ini_options]
|
|
56
|
+
markers = [
|
|
57
|
+
"integration: marks tests as integration tests (deselect with '-m \"not integration\"')",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
[tool.pyrefly]
|
|
61
|
+
project-includes = ["**/*.py*", "**/*.ipynb"]
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: londonaicentre-mesa-runner
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A stateless runner / deployment system for MESA models
|
|
5
|
+
Requires-Python: >=3.13
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: boto3>=1.42.43
|
|
8
|
+
Requires-Dist: duckdb>=1.4.4
|
|
9
|
+
Requires-Dist: londonaicentre-oncoschema>=2.0.1
|
|
10
|
+
Requires-Dist: pandas>=2.3.3
|
|
11
|
+
Requires-Dist: pydantic>=2.12.5
|
|
12
|
+
Requires-Dist: pydantic-settings[yaml]>=2.12.0
|
|
13
|
+
Requires-Dist: snowflake-core>=1.11.0
|
|
14
|
+
Requires-Dist: snowflake-snowpark-python>=1.45.0
|
|
15
|
+
|
|
16
|
+
# MESA Runner
|
|
17
|
+
|
|
18
|
+
A stateless runner for deploying MESA registered models onto GSTT Infrastructure. It syncs models from S3, reads unprocessed documents from Snowflake, runs inference, and writes results back.
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- Python 3.13+
|
|
23
|
+
- [uv](https://github.com/astral-sh/uv) package manager
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
### Remote Inference (Default)
|
|
28
|
+
|
|
29
|
+
For remote inference via OpenAI-compatible endpoints:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
uv sync
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Offline Inference (Optional)
|
|
36
|
+
|
|
37
|
+
For local GPU inference with vLLM, install the optional dependency:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
uv sync --group vllm-offline
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
Create a `config.yaml` file (see example below):
|
|
46
|
+
|
|
47
|
+
### Remote Inference Example
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
my_source:
|
|
51
|
+
model_s3_uri: "s3://aicentre-nlpteam-mesa-build/models/oncoqwen/oncoqwen_1/"
|
|
52
|
+
|
|
53
|
+
inference:
|
|
54
|
+
openai_endpoint: "http://localhost:5000/v1"
|
|
55
|
+
|
|
56
|
+
storage:
|
|
57
|
+
type: snowflake
|
|
58
|
+
source_database: "str"
|
|
59
|
+
source_schema: "str"
|
|
60
|
+
source_table: "str"
|
|
61
|
+
|
|
62
|
+
sink_database: "str"
|
|
63
|
+
sink_schema: "str"
|
|
64
|
+
sink_table: "str"
|
|
65
|
+
|
|
66
|
+
connection_params:
|
|
67
|
+
account: "str"
|
|
68
|
+
user: "str"
|
|
69
|
+
role: "str"
|
|
70
|
+
password: "str"
|
|
71
|
+
warehouse: "str"
|
|
72
|
+
database: "str"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Offline Inference Example
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
my_source:
|
|
79
|
+
model_s3_uri: "s3://aicentre-nlpteam-mesa-build/models/oncoqwen/oncoqwen_1/"
|
|
80
|
+
|
|
81
|
+
inference:
|
|
82
|
+
max_model_len: 18000
|
|
83
|
+
|
|
84
|
+
storage:
|
|
85
|
+
type: snowflake
|
|
86
|
+
source_database: "str"
|
|
87
|
+
source_schema: "str"
|
|
88
|
+
source_table: "str"
|
|
89
|
+
|
|
90
|
+
sink_database: "str"
|
|
91
|
+
sink_schema: "str"
|
|
92
|
+
sink_table: "str"
|
|
93
|
+
|
|
94
|
+
connection_params:
|
|
95
|
+
account: "str"
|
|
96
|
+
user: "str"
|
|
97
|
+
role: "str"
|
|
98
|
+
password: "str"
|
|
99
|
+
warehouse: "str"
|
|
100
|
+
database: "str"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Usage
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Run with default config.yaml
|
|
107
|
+
mesa_runner
|
|
108
|
+
|
|
109
|
+
# Or specify a config file
|
|
110
|
+
mesa_runner --config /path/to/config.yaml
|
|
111
|
+
|
|
112
|
+
# Dry run mode (uses dummy data, does not read or write real data)
|
|
113
|
+
mesa_runner --dry-run
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The dry run mode is useful for testing the runner without accessing real data sources or sinks. It generates 5 dummy documents by default and logs all write operations instead of executing them.
|
|
117
|
+
|
|
118
|
+
## Docker
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Remote inference (default)
|
|
122
|
+
docker build -t mesa-runner .
|
|
123
|
+
docker run mesa-runner
|
|
124
|
+
|
|
125
|
+
# Offline inference (includes vLLM)
|
|
126
|
+
docker build --target offline -t mesa-runner:offline .
|
|
127
|
+
docker run --gpus all mesa-runner:offline
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Development
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Run linting and tests
|
|
134
|
+
make test
|
|
135
|
+
|
|
136
|
+
# Auto-fix linting issues
|
|
137
|
+
make fix
|
|
138
|
+
|
|
139
|
+
# Run tests with coverage
|
|
140
|
+
make cov
|
|
141
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/londonaicentre_mesa_runner.egg-info/PKG-INFO
|
|
4
|
+
src/londonaicentre_mesa_runner.egg-info/SOURCES.txt
|
|
5
|
+
src/londonaicentre_mesa_runner.egg-info/dependency_links.txt
|
|
6
|
+
src/londonaicentre_mesa_runner.egg-info/entry_points.txt
|
|
7
|
+
src/londonaicentre_mesa_runner.egg-info/requires.txt
|
|
8
|
+
src/londonaicentre_mesa_runner.egg-info/top_level.txt
|
|
9
|
+
src/mesa_runner/__init__.py
|
|
10
|
+
src/mesa_runner/inferrer.py
|
|
11
|
+
src/mesa_runner/log_filters.py
|
|
12
|
+
src/mesa_runner/main.py
|
|
13
|
+
src/mesa_runner/runner.py
|
|
14
|
+
src/mesa_runner/adapters/__init__.py
|
|
15
|
+
src/mesa_runner/adapters/dry_run.py
|
|
16
|
+
src/mesa_runner/adapters/filesystem.py
|
|
17
|
+
src/mesa_runner/adapters/io_schemas.py
|
|
18
|
+
src/mesa_runner/adapters/s3.py
|
|
19
|
+
src/mesa_runner/adapters/snowflake.py
|
|
20
|
+
src/mesa_runner/adapters/storage_base.py
|
|
21
|
+
src/mesa_runner/config/__init__.py
|
|
22
|
+
src/mesa_runner/config/config_base.py
|
|
23
|
+
src/mesa_runner/config/filesystem.py
|
|
24
|
+
src/mesa_runner/config/s3.py
|
|
25
|
+
src/mesa_runner/config/snowflake.py
|
|
26
|
+
tests/test_adapter_dry_run.py
|
|
27
|
+
tests/test_adapter_filesystem.py
|
|
28
|
+
tests/test_adapter_s3.py
|
|
29
|
+
tests/test_adapters.py
|
|
30
|
+
tests/test_config.py
|
|
31
|
+
tests/test_inferrer.py
|
|
32
|
+
tests/test_log_filters.py
|
|
33
|
+
tests/test_runtime.py
|
|
34
|
+
tests/test_snowflake_wrapper.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mesa_runner
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from mesa_runner.adapters.storage_base import AbstractStorageAdapter
|
|
2
|
+
from mesa_runner.config.config_base import SourceConfig
|
|
3
|
+
from mesa_runner.config.filesystem import FilesystemStorageConfig
|
|
4
|
+
from mesa_runner.config.s3 import S3StorageConfig
|
|
5
|
+
from mesa_runner.config.snowflake import SnowflakeStorageConfig
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def build_storage_adapter(
|
|
9
|
+
source_config: SourceConfig, dry_run: bool = False
|
|
10
|
+
) -> AbstractStorageAdapter:
|
|
11
|
+
if dry_run:
|
|
12
|
+
from mesa_runner.adapters.dry_run import DryRunStorageAdapter
|
|
13
|
+
|
|
14
|
+
return DryRunStorageAdapter()
|
|
15
|
+
|
|
16
|
+
if source_config.storage.type == "snowflake":
|
|
17
|
+
from mesa_runner.adapters.snowflake import SnowflakeWrapper
|
|
18
|
+
|
|
19
|
+
# Assertion to help type checking
|
|
20
|
+
assert isinstance(source_config.storage, SnowflakeStorageConfig)
|
|
21
|
+
|
|
22
|
+
return SnowflakeWrapper(
|
|
23
|
+
params=source_config.storage.connection_params, storage_config=source_config.storage
|
|
24
|
+
)
|
|
25
|
+
elif source_config.storage.type == "s3":
|
|
26
|
+
from mesa_runner.adapters.s3 import S3Adapter
|
|
27
|
+
|
|
28
|
+
assert isinstance(source_config.storage, S3StorageConfig)
|
|
29
|
+
|
|
30
|
+
# TODO CHANGE - this needs to be passed through more intelligently
|
|
31
|
+
return S3Adapter(
|
|
32
|
+
storage_config=source_config.storage,
|
|
33
|
+
model_name=source_config.model_name,
|
|
34
|
+
)
|
|
35
|
+
elif source_config.storage.type == "filesystem":
|
|
36
|
+
from mesa_runner.adapters.filesystem import FileSystemAdapter
|
|
37
|
+
|
|
38
|
+
assert isinstance(source_config.storage, FilesystemStorageConfig)
|
|
39
|
+
|
|
40
|
+
# TODO CHANGE - this needs to be passed through more intelligently
|
|
41
|
+
return FileSystemAdapter(
|
|
42
|
+
storage_config=source_config.storage,
|
|
43
|
+
model_name=source_config.model_name,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
else:
|
|
47
|
+
raise ValueError(f"Unknown storage type: {source_config.storage.type}")
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import random
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import Generator
|
|
5
|
+
|
|
6
|
+
from mesa_runner.adapters.io_schemas import DocumentInput, InferenceResult
|
|
7
|
+
from mesa_runner.adapters.storage_base import AbstractStorageAdapter
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class DryRunStorageAdapter(AbstractStorageAdapter):
|
|
11
|
+
_WORD_POOL: list[str] = [
|
|
12
|
+
"patient",
|
|
13
|
+
"diagnosis",
|
|
14
|
+
"treatment",
|
|
15
|
+
"history",
|
|
16
|
+
"medical",
|
|
17
|
+
"clinical",
|
|
18
|
+
"symptoms",
|
|
19
|
+
"examination",
|
|
20
|
+
"results",
|
|
21
|
+
"assessment",
|
|
22
|
+
"procedure",
|
|
23
|
+
"medication",
|
|
24
|
+
"therapy",
|
|
25
|
+
"condition",
|
|
26
|
+
"report",
|
|
27
|
+
"findings",
|
|
28
|
+
"analysis",
|
|
29
|
+
"consultation",
|
|
30
|
+
"follow",
|
|
31
|
+
"up",
|
|
32
|
+
"review",
|
|
33
|
+
"outcome",
|
|
34
|
+
"prognosis",
|
|
35
|
+
"investigation",
|
|
36
|
+
"referral",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
def __init__(self, document_count: int = 5):
|
|
40
|
+
self.__document_count: int = document_count
|
|
41
|
+
self.__logger: logging.Logger = logging.getLogger(f"{__name__}.{self.__class__.__name__}")
|
|
42
|
+
super().__init__()
|
|
43
|
+
|
|
44
|
+
def _generate_random_content(self, min_words: int = 10, max_words: int = 100) -> str:
|
|
45
|
+
return " ".join(random.choices(self._WORD_POOL, k=random.randint(min_words, max_words)))
|
|
46
|
+
|
|
47
|
+
def get_unprocessed_document_count(self) -> int:
|
|
48
|
+
return self.__document_count
|
|
49
|
+
|
|
50
|
+
def get_documents(self) -> Generator[DocumentInput, None, None]:
|
|
51
|
+
for index in range(self.__document_count):
|
|
52
|
+
yield DocumentInput(
|
|
53
|
+
document_id=f"dry_run_doc_{index}",
|
|
54
|
+
document_content=self._generate_random_content(),
|
|
55
|
+
document_update_dt=datetime.now(),
|
|
56
|
+
document_source={"source": "dry_run", "index": index},
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
def write_document(self, documents: list[InferenceResult]):
|
|
60
|
+
self.__logger.info(f"Would write {len(documents)} documents")
|
|
61
|
+
|
|
62
|
+
def _check_document_output_writable(self):
|
|
63
|
+
pass
|
|
64
|
+
|
|
65
|
+
def _check_document_source_exists(self):
|
|
66
|
+
pass
|
|
67
|
+
|
|
68
|
+
def flush(self):
|
|
69
|
+
pass
|