compox 2.0.0.dev2__tar.gz → 2.1.0.dev1__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.
- compox-2.1.0.dev1/PKG-INFO +154 -0
- compox-2.1.0.dev1/README.md +119 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/pyproject.toml +1 -1
- compox-2.1.0.dev1/src/compox/algorithm_debug.py +90 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/algorithm_utils/AlgorithmDeployer.py +15 -10
- compox-2.1.0.dev1/src/compox/algorithm_utils/LocalDebugSession.py +307 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/algorithm_utils/io_schemas.py +6 -2
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/cli.py +2 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/config/server_settings.py +3 -3
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/routers/root.py +4 -2
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/version.py +1 -1
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/dummy/README.md +1 -1
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_algorithm_deployer.py +1 -1
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_server.yaml +3 -3
- compox-2.0.0.dev2/PKG-INFO +0 -278
- compox-2.0.0.dev2/README.md +0 -243
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/LICENSE +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/NOTICE +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/THIRD_PARTY_LICENSES.txt +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/__init__.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/algorithm_utils/AlgorithmConfigSchema.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/algorithm_utils/AlgorithmManager.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/algorithm_utils/BaseRunner.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/algorithm_utils/Image2AlignmentRunner.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/algorithm_utils/Image2EmbeddingRunner.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/algorithm_utils/Image2ImageRunner.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/algorithm_utils/Image2SegmentationRunner.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/algorithm_utils/Segmentation2SegmentationRunner.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/algorithm_utils/__init__.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/algorithm_utils/deployment_utils.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/algorithm_utils/runner_context.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/components/api_builder.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/components/celery_builder.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/components/db_connection_builder.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/components/minio_wrapper.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/components/server_builder.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/database_connection/BaseConnection.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/database_connection/InMemoryConnection.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/database_connection/S3Connection.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/database_connection/TempfileConnection.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/database_connection/__init__.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/database_connection/database_utils.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/deploy_algorithms.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/internal/CUDAMemoryManager.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/internal/JobPOpen.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/internal/ServerSystrayInterface.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/internal/__init__.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/internal/downloader.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/internal/logging.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/pydantic_models.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/resources/compoxbackend.ico +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/routers/__init__.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/routers/algorithms_controller.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/routers/execution_controller.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/routers/execution_manager.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/routers/file_controller.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/routers/file_controller_v1.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/run_server.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/run_worker.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/server_utils.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/session/DataCache.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/session/TaskSession.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/session/__init__.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/tasks/DebuggingTaskHandler.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/tasks/TaskHandler.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/tasks/__init__.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/tasks/celery_task.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/tasks/context_task_handler.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/src/compox/tasks/fastapi_background_task.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/.gitignore +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/__init__.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/bar/Runner.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/bar/__init__.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/bar/dependencies/some_more_files/__init__.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/bar/dependencies/some_more_files/layer.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/bar/dependencies/some_more_files/layer2.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/bar/dependencies/utils.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/bar/main.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/bar/pyproject.toml +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/dummy/Runner.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/dummy/__init__.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/dummy/pyproject.toml +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/foo/Runner.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/foo/__init__.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/foo/dependencies/__init__.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/foo/dependencies/some_more_files/__init__.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/foo/dependencies/some_more_files/layer.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/foo/dependencies/some_more_files/layer2.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/foo/dependencies/utils.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/foo/main.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/algorithms/foo/pyproject.toml +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/conftest.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/pytest.ini +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_base_runner.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_child_runners.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_datacache.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_delete_file.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_execute_algorithm.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_file_controller_v1.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_get_algorithm.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_get_all_algorithms.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_get_execution_record.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_get_file.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_post_file.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_runner_attribute_behavior.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_server_utils.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_stress.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_task_handler.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_task_session.py +0 -0
- {compox-2.0.0.dev2 → compox-2.1.0.dev1}/tests/test_utils.py +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: compox
|
|
3
|
+
Version: 2.1.0.dev1
|
|
4
|
+
Author-Email: Jan Matula <jan.matula@tescan.com>, =?utf-8?q?Old=C5=99ich_Kodym?= <oldrich.kodym@tescan.com>
|
|
5
|
+
License-Expression: Apache-2.0 AND LicenseRef-Commons-Clause-1.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
License-File: NOTICE
|
|
8
|
+
License-File: THIRD_PARTY_LICENSES.txt
|
|
9
|
+
Requires-Python: >=3.10.0
|
|
10
|
+
Requires-Dist: fastapi>=0.100.1
|
|
11
|
+
Requires-Dist: boto3>=1.36.0
|
|
12
|
+
Requires-Dist: celery==5.3.1
|
|
13
|
+
Requires-Dist: uvicorn>=0.25.0
|
|
14
|
+
Requires-Dist: h5py>=3.9.0
|
|
15
|
+
Requires-Dist: numpy<2.0.0
|
|
16
|
+
Requires-Dist: natsort==8.4.0
|
|
17
|
+
Requires-Dist: pytest>=7.4.2
|
|
18
|
+
Requires-Dist: pydantic-settings>=2.0.3
|
|
19
|
+
Requires-Dist: python-minifier>=2.9.0
|
|
20
|
+
Requires-Dist: pystray>=0.19.5
|
|
21
|
+
Requires-Dist: pywin32>=306; platform_system == "Windows"
|
|
22
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
23
|
+
Requires-Dist: toml>=0.10.2
|
|
24
|
+
Requires-Dist: flower>=2.0.1
|
|
25
|
+
Requires-Dist: python-multipart>=0.0.20
|
|
26
|
+
Requires-Dist: mangum>=0.19.0
|
|
27
|
+
Requires-Dist: requests==2.32.3
|
|
28
|
+
Requires-Dist: pycurl>=7.45.4
|
|
29
|
+
Requires-Dist: loguru>=0.7.3
|
|
30
|
+
Requires-Dist: typer>=0.16.0
|
|
31
|
+
Requires-Dist: pip>=25.2
|
|
32
|
+
Requires-Dist: build>=1.3.0
|
|
33
|
+
Requires-Dist: pdm-backend>=2.4.5
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# Compox
|
|
37
|
+
Compox is a simple Python execution engine for Tescan applications. It's purpose is to run data processing algorithms written in Python on the server and report the results to the client application such as Tescan 3D Viewer or Picannto.
|
|
38
|
+
|
|
39
|
+
See the [GitHub pages](https://tescan-3dim.github.io/compox) for full python API reference, docs and tutorials!
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
Compox can be installed through PyPI:
|
|
43
|
+
```bash
|
|
44
|
+
pip install compox
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
You can also install the server by cloning this repository and installing it from source.
|
|
48
|
+
|
|
49
|
+
Note that some additional dependencies, such as MinIO executable for your operating system, will be downloaded on the first run of the server.
|
|
50
|
+
|
|
51
|
+
## Running the server
|
|
52
|
+
Once installed into your Python environment, Compox can be run using the `compox` command. This command is available in the virtual environment
|
|
53
|
+
created during the setup process. Run the following command to list the available commands:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
compox --help
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
It's recommended to start with generating an initial configuration file with `compox generate-config`. See the configuration options section below.
|
|
60
|
+
To see the usage of the `generate-config` command, you can run:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
compox generate-config --help
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
To run the Compox, use the following command:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
compox run --config /path/to/config.yaml
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Deploying algorithms
|
|
73
|
+
See Algorithm development tutorial for information about target structure of the deployable algorithms.
|
|
74
|
+
|
|
75
|
+
Once your algorithm is ready, you can use the `compox deploy-algorithms` command to deploy it to your server.
|
|
76
|
+
To see the usage of the `deploy-algorithms` command, you can run:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
compox deploy-algorithms --help
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
This command will read the algorithm definitions from the folder specified in your configuration file with the `deploy_algorithms_from` key
|
|
83
|
+
and deploy them to the server. For example:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
compox deploy-algorithms --config /path/to/config.yaml
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Note that the server does not need to be running in order to deploy the algorithms.
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
## Configuration
|
|
93
|
+
The server uses pydantic settings for configuration. The options can be either set as runtime arguments, in a yaml file, or using the `COMPOX__` environment variables, in corresponding order of precedence.
|
|
94
|
+
|
|
95
|
+
- Ensure all paths and URLs are correctly set before running the application.
|
|
96
|
+
- Adjust CUDA settings based on hardware capabilities.
|
|
97
|
+
- Logging paths should be accessible by the application to prevent errors.
|
|
98
|
+
- See the [configuration reference](#configuration-reference) below for detailed configuration options.
|
|
99
|
+
|
|
100
|
+
<details><summary>Configuration reference</summary>
|
|
101
|
+
|
|
102
|
+
<br>
|
|
103
|
+
|
|
104
|
+
### Compox Configuration Reference
|
|
105
|
+
|
|
106
|
+
| Section | Field | Default | Description |
|
|
107
|
+
|----------------------------------|-----------------------------|------------------------------------|-----------------------------------------------------------------------------|
|
|
108
|
+
| | `port` | `5461` | The main server port used to make requests |
|
|
109
|
+
| | `deploy_algorithms_from` | `"./algorithms"` | Directory for algorithm deployment sources. |
|
|
110
|
+
| | `log_path` | `"LOG_DEFAULT:compox.log"` | Path to the main log file (supports dynamic prefixes). |
|
|
111
|
+
| | `config` | `None` | Optional config path override. |
|
|
112
|
+
| `info` | `product_name` | `"TESCAN 3D Backend"` | Product display name. |
|
|
113
|
+
| `info` | `server_tags` | `[]` → auto appends `"compox"` | Tags attached to the server. `"compox"` is added automatically. |
|
|
114
|
+
| `info` | `group_name` | `"TESCAN GROUP, a.s."` | Name of the corporate group. |
|
|
115
|
+
| `info` | `organization_name` | `"TESCAN 3DIM, s.r.o."` | Full name of the organization. |
|
|
116
|
+
| `info` | `organization_domain` | `"tescan3dim.com"` | Domain used in server configuration. |
|
|
117
|
+
| `gui` | `algorithm_add_remove_in_menus` | `False` | Enables/disables GUI menu for algorithm management. |
|
|
118
|
+
| `gui` | `use_systray` | `False` | Enables/disables systray GUI integration. |
|
|
119
|
+
| `gui` | `icon_path` | Path to the installed package resource | Path to the systray icon (supports dynamic prefixes) |
|
|
120
|
+
| `inference` | `device` | `"cuda"` | Device used for model inference (`"cpu"`, `"cuda"`, `"mps"`). |
|
|
121
|
+
| `inference` | `cuda_visible_devices` | `"0"` | Comma-separated list of visible CUDA GPUs. |
|
|
122
|
+
| `storage` | `collection_prefix` | `""` | Prefix applied to object store collections. (useful for AWS s3 store, where unique bucket names are needed)|
|
|
123
|
+
| `storage` | `data_store_expire_days` | `1` | Number of days until stored datasets expire. |
|
|
124
|
+
| `storage` | `access_key_id` | generated with `UUIDv4` | Generated access key for storage backend. If `null` is provided, random UUIDv4 is generated. |
|
|
125
|
+
| `storage` | `secret_access_key` | generated with `UUIDv4` | Generated secret key for storage backend. If `null` is provided, random UUIDv4 is generated. |S
|
|
126
|
+
| `storage.backend_settings` (minio) | `provider` | `"minio"` | Selected backend provider. |
|
|
127
|
+
| `storage.backend_settings` (minio) | `start_instance` | `True` | Whether to start a local MinIO server. |
|
|
128
|
+
| `storage.backend_settings` (minio) | `port` | `9091` | MinIO service port. |
|
|
129
|
+
| `storage.backend_settings` (minio) | `console_port` | `9090` | MinIO admin console port. |
|
|
130
|
+
| `storage.backend_settings` (minio) | `executable_path` | `"minio/minio_bin"` | Path to the MinIO binary (accepts dynamic prefixes). |
|
|
131
|
+
| `storage.backend_settings` (minio) | `storage_path` | `"minio/compox_store"` | Storage directory used by MinIO (accepts dynamic prefixes). |
|
|
132
|
+
| `storage.backend_settings` (minio) | `aws_region` | `None` | Optional AWS compatibility region. |
|
|
133
|
+
| `storage.backend_settings` (minio) | `s3_domain_name` | `None` | Optional domain override for S3 compatibility. |
|
|
134
|
+
| `storage.backend_settings` (minio) | `s3_endpoint_url` | Derived from `port` | Computed as `http://localhost:{port}`. |
|
|
135
|
+
| `storage.backend_settings` (aws) | `provider` | `"aws"` | AWS backend selection. |
|
|
136
|
+
| `storage.backend_settings` (aws) | `s3_endpoint_url` | `None` | Optional override for S3 endpoint URL. |
|
|
137
|
+
| `storage.backend_settings` (aws) | `aws_region` | `None` | AWS region (e.g. `us-east-1`). |
|
|
138
|
+
| `storage.backend_settings` (aws) | `s3_domain_name` | `None` | Domain used for S3-style URLs. |
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
Some fields in the Compox configuration (such as `log_path`, `icon_path`, etc.) support **dynamic prefixes** that resolve to OS-specific or runtime-specific paths. This allows for portability across platforms (e.g., Windows, Linux) and between development and production environments.
|
|
142
|
+
|
|
143
|
+
#### Supported Prefixes
|
|
144
|
+
|
|
145
|
+
| Prefix | Meaning (Resolved To...) |
|
|
146
|
+
|--------------------------|------------------------------------------------------------------------------------------|
|
|
147
|
+
| `LOG_DEFAULT:` | A platform-dependent log directory: |
|
|
148
|
+
| | - Windows: `%TEMP%/<organization>/<product>` |
|
|
149
|
+
| | - Linux/macOS: `/var/log/<organization>/<product>` |
|
|
150
|
+
| `PROGRAMDATA_DEFAULT:` | A system-wide data directory (Windows only): |
|
|
151
|
+
| | - e.g., `%PROGRAMDATA%/<organization>/<product>` |
|
|
152
|
+
| | - On Linux/macOS, defaults to `"."` (current dir) |
|
|
153
|
+
|
|
154
|
+
These are resolved **at runtime** in the `Settings.parse_paths()` validator method.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Compox
|
|
2
|
+
Compox is a simple Python execution engine for Tescan applications. It's purpose is to run data processing algorithms written in Python on the server and report the results to the client application such as Tescan 3D Viewer or Picannto.
|
|
3
|
+
|
|
4
|
+
See the [GitHub pages](https://tescan-3dim.github.io/compox) for full python API reference, docs and tutorials!
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
Compox can be installed through PyPI:
|
|
8
|
+
```bash
|
|
9
|
+
pip install compox
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
You can also install the server by cloning this repository and installing it from source.
|
|
13
|
+
|
|
14
|
+
Note that some additional dependencies, such as MinIO executable for your operating system, will be downloaded on the first run of the server.
|
|
15
|
+
|
|
16
|
+
## Running the server
|
|
17
|
+
Once installed into your Python environment, Compox can be run using the `compox` command. This command is available in the virtual environment
|
|
18
|
+
created during the setup process. Run the following command to list the available commands:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
compox --help
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
It's recommended to start with generating an initial configuration file with `compox generate-config`. See the configuration options section below.
|
|
25
|
+
To see the usage of the `generate-config` command, you can run:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
compox generate-config --help
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
To run the Compox, use the following command:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
compox run --config /path/to/config.yaml
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Deploying algorithms
|
|
38
|
+
See Algorithm development tutorial for information about target structure of the deployable algorithms.
|
|
39
|
+
|
|
40
|
+
Once your algorithm is ready, you can use the `compox deploy-algorithms` command to deploy it to your server.
|
|
41
|
+
To see the usage of the `deploy-algorithms` command, you can run:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
compox deploy-algorithms --help
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This command will read the algorithm definitions from the folder specified in your configuration file with the `deploy_algorithms_from` key
|
|
48
|
+
and deploy them to the server. For example:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
compox deploy-algorithms --config /path/to/config.yaml
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Note that the server does not need to be running in order to deploy the algorithms.
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## Configuration
|
|
58
|
+
The server uses pydantic settings for configuration. The options can be either set as runtime arguments, in a yaml file, or using the `COMPOX__` environment variables, in corresponding order of precedence.
|
|
59
|
+
|
|
60
|
+
- Ensure all paths and URLs are correctly set before running the application.
|
|
61
|
+
- Adjust CUDA settings based on hardware capabilities.
|
|
62
|
+
- Logging paths should be accessible by the application to prevent errors.
|
|
63
|
+
- See the [configuration reference](#configuration-reference) below for detailed configuration options.
|
|
64
|
+
|
|
65
|
+
<details><summary>Configuration reference</summary>
|
|
66
|
+
|
|
67
|
+
<br>
|
|
68
|
+
|
|
69
|
+
### Compox Configuration Reference
|
|
70
|
+
|
|
71
|
+
| Section | Field | Default | Description |
|
|
72
|
+
|----------------------------------|-----------------------------|------------------------------------|-----------------------------------------------------------------------------|
|
|
73
|
+
| | `port` | `5461` | The main server port used to make requests |
|
|
74
|
+
| | `deploy_algorithms_from` | `"./algorithms"` | Directory for algorithm deployment sources. |
|
|
75
|
+
| | `log_path` | `"LOG_DEFAULT:compox.log"` | Path to the main log file (supports dynamic prefixes). |
|
|
76
|
+
| | `config` | `None` | Optional config path override. |
|
|
77
|
+
| `info` | `product_name` | `"TESCAN 3D Backend"` | Product display name. |
|
|
78
|
+
| `info` | `server_tags` | `[]` → auto appends `"compox"` | Tags attached to the server. `"compox"` is added automatically. |
|
|
79
|
+
| `info` | `group_name` | `"TESCAN GROUP, a.s."` | Name of the corporate group. |
|
|
80
|
+
| `info` | `organization_name` | `"TESCAN 3DIM, s.r.o."` | Full name of the organization. |
|
|
81
|
+
| `info` | `organization_domain` | `"tescan3dim.com"` | Domain used in server configuration. |
|
|
82
|
+
| `gui` | `algorithm_add_remove_in_menus` | `False` | Enables/disables GUI menu for algorithm management. |
|
|
83
|
+
| `gui` | `use_systray` | `False` | Enables/disables systray GUI integration. |
|
|
84
|
+
| `gui` | `icon_path` | Path to the installed package resource | Path to the systray icon (supports dynamic prefixes) |
|
|
85
|
+
| `inference` | `device` | `"cuda"` | Device used for model inference (`"cpu"`, `"cuda"`, `"mps"`). |
|
|
86
|
+
| `inference` | `cuda_visible_devices` | `"0"` | Comma-separated list of visible CUDA GPUs. |
|
|
87
|
+
| `storage` | `collection_prefix` | `""` | Prefix applied to object store collections. (useful for AWS s3 store, where unique bucket names are needed)|
|
|
88
|
+
| `storage` | `data_store_expire_days` | `1` | Number of days until stored datasets expire. |
|
|
89
|
+
| `storage` | `access_key_id` | generated with `UUIDv4` | Generated access key for storage backend. If `null` is provided, random UUIDv4 is generated. |
|
|
90
|
+
| `storage` | `secret_access_key` | generated with `UUIDv4` | Generated secret key for storage backend. If `null` is provided, random UUIDv4 is generated. |S
|
|
91
|
+
| `storage.backend_settings` (minio) | `provider` | `"minio"` | Selected backend provider. |
|
|
92
|
+
| `storage.backend_settings` (minio) | `start_instance` | `True` | Whether to start a local MinIO server. |
|
|
93
|
+
| `storage.backend_settings` (minio) | `port` | `9091` | MinIO service port. |
|
|
94
|
+
| `storage.backend_settings` (minio) | `console_port` | `9090` | MinIO admin console port. |
|
|
95
|
+
| `storage.backend_settings` (minio) | `executable_path` | `"minio/minio_bin"` | Path to the MinIO binary (accepts dynamic prefixes). |
|
|
96
|
+
| `storage.backend_settings` (minio) | `storage_path` | `"minio/compox_store"` | Storage directory used by MinIO (accepts dynamic prefixes). |
|
|
97
|
+
| `storage.backend_settings` (minio) | `aws_region` | `None` | Optional AWS compatibility region. |
|
|
98
|
+
| `storage.backend_settings` (minio) | `s3_domain_name` | `None` | Optional domain override for S3 compatibility. |
|
|
99
|
+
| `storage.backend_settings` (minio) | `s3_endpoint_url` | Derived from `port` | Computed as `http://localhost:{port}`. |
|
|
100
|
+
| `storage.backend_settings` (aws) | `provider` | `"aws"` | AWS backend selection. |
|
|
101
|
+
| `storage.backend_settings` (aws) | `s3_endpoint_url` | `None` | Optional override for S3 endpoint URL. |
|
|
102
|
+
| `storage.backend_settings` (aws) | `aws_region` | `None` | AWS region (e.g. `us-east-1`). |
|
|
103
|
+
| `storage.backend_settings` (aws) | `s3_domain_name` | `None` | Domain used for S3-style URLs. |
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
Some fields in the Compox configuration (such as `log_path`, `icon_path`, etc.) support **dynamic prefixes** that resolve to OS-specific or runtime-specific paths. This allows for portability across platforms (e.g., Windows, Linux) and between development and production environments.
|
|
107
|
+
|
|
108
|
+
#### Supported Prefixes
|
|
109
|
+
|
|
110
|
+
| Prefix | Meaning (Resolved To...) |
|
|
111
|
+
|--------------------------|------------------------------------------------------------------------------------------|
|
|
112
|
+
| `LOG_DEFAULT:` | A platform-dependent log directory: |
|
|
113
|
+
| | - Windows: `%TEMP%/<organization>/<product>` |
|
|
114
|
+
| | - Linux/macOS: `/var/log/<organization>/<product>` |
|
|
115
|
+
| `PROGRAMDATA_DEFAULT:` | A system-wide data directory (Windows only): |
|
|
116
|
+
| | - e.g., `%PROGRAMDATA%/<organization>/<product>` |
|
|
117
|
+
| | - On Linux/macOS, defaults to `"."` (current dir) |
|
|
118
|
+
|
|
119
|
+
These are resolved **at runtime** in the `Settings.parse_paths()` validator method.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import json, typer
|
|
2
|
+
from typing import Optional, Annotated
|
|
3
|
+
|
|
4
|
+
from compox.algorithm_utils.LocalDebugSession import LocalDebugSession
|
|
5
|
+
|
|
6
|
+
app = typer.Typer(help="Commands for local debugging of algorithms")
|
|
7
|
+
|
|
8
|
+
def parse_params(value: Optional[str]) -> Optional[dict]:
|
|
9
|
+
"""
|
|
10
|
+
Parse a JSON string of algorithm parameters from the command line.
|
|
11
|
+
|
|
12
|
+
Parameters
|
|
13
|
+
----------
|
|
14
|
+
value : str | None
|
|
15
|
+
A JSON string containing algorithm parameters.
|
|
16
|
+
|
|
17
|
+
Returns
|
|
18
|
+
-------
|
|
19
|
+
dict | None
|
|
20
|
+
Parsed dictionary of parameters, or ``None`` if no input was provided.
|
|
21
|
+
|
|
22
|
+
Raises
|
|
23
|
+
------
|
|
24
|
+
typer.BadParameter
|
|
25
|
+
If the string cannot be parsed as valid JSON.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
if value is None or value == "":
|
|
29
|
+
return None
|
|
30
|
+
try:
|
|
31
|
+
return json.loads(value)
|
|
32
|
+
except json.JSONDecodeError as e:
|
|
33
|
+
raise typer.BadParameter(f"--params must be valid JSON: {e}")
|
|
34
|
+
|
|
35
|
+
@app.command("run")
|
|
36
|
+
def debug_run(
|
|
37
|
+
algo: str = typer.Option(".", help="Path to algorithm folder"),
|
|
38
|
+
data: str = typer.Option(..., help="Path to dataset folder (e.g. PNG/TIF stack)"),
|
|
39
|
+
device: str = typer.Option("cpu", help="Device to run on (cpu/cuda)"),
|
|
40
|
+
params: Annotated[Optional[str], typer.Option("--params", callback=parse_params, help="Algorithm params (JSON)")] = None,
|
|
41
|
+
):
|
|
42
|
+
"""
|
|
43
|
+
Run an algorithm locally in debug mode (without Compox backend).
|
|
44
|
+
|
|
45
|
+
Parameters
|
|
46
|
+
----------
|
|
47
|
+
algo : str
|
|
48
|
+
Path to the algorithm directory.
|
|
49
|
+
data : str
|
|
50
|
+
Path to the folder containing image slices.
|
|
51
|
+
device : str
|
|
52
|
+
Target device to execute the algorithm on.
|
|
53
|
+
params : dict | None
|
|
54
|
+
Algorithm parameters.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
debug(algo_dir=algo, data=data, params=params, device=device)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def debug(algo_dir=".", data=".", params=None, device="cpu"):
|
|
61
|
+
"""
|
|
62
|
+
Run a local debugging session. The function initializes a `LocalDebugSession`,
|
|
63
|
+
loads an image stack from the specified folder, uploads it into the temporary
|
|
64
|
+
database, and executes the algorithm in the given directory.
|
|
65
|
+
|
|
66
|
+
Parameters
|
|
67
|
+
----------
|
|
68
|
+
algo_dir : str, optional
|
|
69
|
+
Path to the algorithm folder. Default is the current directory (".").
|
|
70
|
+
data : str, optional
|
|
71
|
+
Path to the dataset folder (e.g. a directory with PNG/TIF slices).
|
|
72
|
+
params : dict, optional
|
|
73
|
+
Dictionary of algorithm parameters.
|
|
74
|
+
device : str, optional
|
|
75
|
+
Target device for execution. Default is "cpu".
|
|
76
|
+
|
|
77
|
+
Returns
|
|
78
|
+
-------
|
|
79
|
+
Any
|
|
80
|
+
Output returned by the algorithm’s ``run()`` method.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
sess = LocalDebugSession(device=device)
|
|
84
|
+
input_ids = sess.load_data(data)
|
|
85
|
+
out = sess.run(algo_dir, {"input_dataset_ids": input_ids}, args=params or {})
|
|
86
|
+
print(out)
|
|
87
|
+
return out
|
|
88
|
+
|
|
89
|
+
if __name__ == "__main__":
|
|
90
|
+
app()
|
|
@@ -11,6 +11,7 @@ import shutil
|
|
|
11
11
|
import glob
|
|
12
12
|
import tempfile
|
|
13
13
|
import zipimport
|
|
14
|
+
import importlib
|
|
14
15
|
import sys
|
|
15
16
|
import re
|
|
16
17
|
import hashlib
|
|
@@ -99,12 +100,10 @@ class AlgorithmDeployer:
|
|
|
99
100
|
"additional_parameters"
|
|
100
101
|
]
|
|
101
102
|
|
|
102
|
-
self.check_importable = pyproject_toml
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
self.
|
|
106
|
-
self.hash_module = pyproject_toml["tool"]["compox"]["hash_module"]
|
|
107
|
-
self.hash_assets = pyproject_toml["tool"]["compox"]["hash_assets"]
|
|
103
|
+
self.check_importable = pyproject_toml.get("tool", {}).get("compox", {}).get("check_importable", False)
|
|
104
|
+
self.obfuscate = pyproject_toml.get("tool", {}).get("compox", {}).get("obfuscate", True)
|
|
105
|
+
self.hash_module = pyproject_toml.get("tool", {}).get("compox", {}).get("hash_module", True)
|
|
106
|
+
self.hash_assets = pyproject_toml.get("tool", {}).get("compox", {}).get("hash_assets", True)
|
|
108
107
|
|
|
109
108
|
def parse_pyproject_toml(self, path_to_algorithm_directory: str) -> dict:
|
|
110
109
|
"""
|
|
@@ -382,7 +381,9 @@ class AlgorithmDeployer:
|
|
|
382
381
|
module_path + ".zip"
|
|
383
382
|
)
|
|
384
383
|
if not importable:
|
|
385
|
-
raise ValueError(
|
|
384
|
+
raise ValueError(
|
|
385
|
+
"The current environment cannot import the the algorithm module. Check the above logs for more details about the ImportError cause. This check can be disabled by setting check_importable to False in the affected algorithm's pyproject.toml file."
|
|
386
|
+
)
|
|
386
387
|
|
|
387
388
|
zip_bytes = open(module_path + ".zip", "rb").read()
|
|
388
389
|
# store the zip file in the module-store collection
|
|
@@ -767,10 +768,14 @@ class AlgorithmDeployer:
|
|
|
767
768
|
"""
|
|
768
769
|
try:
|
|
769
770
|
sys.path.insert(0, path_to_zip)
|
|
770
|
-
|
|
771
|
-
|
|
771
|
+
importer = zipimport.zipimporter(path_to_zip)
|
|
772
|
+
spec = importlib.util.spec_from_loader("Runner", importer)
|
|
773
|
+
if spec is not None:
|
|
774
|
+
module = importlib.util.module_from_spec(spec)
|
|
775
|
+
importer.exec_module(module)
|
|
772
776
|
return True
|
|
773
|
-
except
|
|
777
|
+
except ImportError as e:
|
|
778
|
+
logger.error(f"ImportError: {e}")
|
|
774
779
|
return False
|
|
775
780
|
|
|
776
781
|
@staticmethod
|