mstransfer 0.1.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.
@@ -0,0 +1,45 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ id-token: write
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Install uv
17
+ uses: astral-sh/setup-uv@v5
18
+
19
+ - name: Set up Python
20
+ run: uv python install 3.10
21
+
22
+ - name: Build package
23
+ run: uv build
24
+
25
+ - name: Upload build artifacts
26
+ uses: actions/upload-artifact@v4
27
+ with:
28
+ name: dist
29
+ path: dist/
30
+
31
+ publish:
32
+ runs-on: ubuntu-latest
33
+ needs: build
34
+ environment: pypi
35
+ permissions:
36
+ id-token: write
37
+ steps:
38
+ - name: Download build artifacts
39
+ uses: actions/download-artifact@v4
40
+ with:
41
+ name: dist
42
+ path: dist/
43
+
44
+ - name: Publish to PyPI
45
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,39 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [dev, stage, main]
6
+ pull_request:
7
+ branches: [dev, stage, main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v5
21
+
22
+ - name: Set up Python ${{ matrix.python-version }}
23
+ run: uv python install ${{ matrix.python-version }}
24
+
25
+ - name: Install dependencies
26
+ run: uv sync --dev
27
+
28
+ - name: Lint
29
+ run: uv run ruff check .
30
+
31
+ - name: Run tests with coverage
32
+ run: uv run pytest --cov=mstransfer --cov-report=term-missing --cov-report=xml
33
+
34
+ - name: Upload coverage to Codecov
35
+ if: matrix.python-version == '3.10'
36
+ uses: codecov/codecov-action@v5
37
+ with:
38
+ token: ${{ secrets.CODECOV_TOKEN }}
39
+ files: coverage.xml
@@ -0,0 +1,21 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Coverage
13
+ .coverage
14
+ coverage.xml
15
+
16
+ # Received files
17
+ received/
18
+
19
+ # OS generated files
20
+ .DS_Store
21
+ Thumbs.db
@@ -0,0 +1,15 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.9.1
4
+ hooks:
5
+ - id: ruff
6
+ args: [--fix]
7
+ - id: ruff-format
8
+ - repo: local
9
+ hooks:
10
+ - id: pyright
11
+ name: pyright
12
+ entry: uv run pyright
13
+ language: system
14
+ types: [python]
15
+ pass_filenames: false
@@ -0,0 +1 @@
1
+ 3.10
@@ -0,0 +1,7 @@
1
+ {
2
+ "python.testing.pytestArgs": [
3
+ "tests"
4
+ ],
5
+ "python.testing.unittestEnabled": false,
6
+ "python.testing.pytestEnabled": true
7
+ }
@@ -0,0 +1,173 @@
1
+ Metadata-Version: 2.4
2
+ Name: mstransfer
3
+ Version: 0.1.0
4
+ Summary: Transfer mass spectrometry files (mzML/MSZ) between endpoints using mscompress
5
+ Requires-Python: >=3.10
6
+ Requires-Dist: aiofiles
7
+ Requires-Dist: fastapi
8
+ Requires-Dist: httpx
9
+ Requires-Dist: mscompress
10
+ Requires-Dist: pydantic>=2.0
11
+ Requires-Dist: python-multipart
12
+ Requires-Dist: rich
13
+ Requires-Dist: uvicorn[standard]
14
+ Description-Content-Type: text/markdown
15
+
16
+ # mstransfer
17
+
18
+ [![Tests](https://github.com/chrisagrams/mstransfer/actions/workflows/test.yml/badge.svg)](https://github.com/chrisagrams/mstransfer/actions/workflows/test.yml)
19
+ [![codecov](https://codecov.io/gh/chrisagrams/mstransfer/graph/badge.svg)](https://codecov.io/gh/chrisagrams/mstransfer)
20
+
21
+ Transfer mass spectrometry files (mzML / MSZ) between machines over HTTP. Files are always transported in compressed MSZ format using [mscompress](https://github.com/chrisagrams/mscompress) — mzML sources are compressed on-the-fly without temp files, and the receiving end can optionally decompress back to mzML.
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ # Recommended — installs as an isolated CLI tool
27
+ uv tool install mstransfer
28
+
29
+ # Or with pipx
30
+ pipx install mstransfer
31
+
32
+ # Or as a project dependency
33
+ uv pip install mstransfer
34
+ pip install mstransfer
35
+ ```
36
+
37
+ ## Quick start
38
+
39
+ Start a server on the receiving machine:
40
+
41
+ ```bash
42
+ mstransfer serve --port 1319 --store-as msz
43
+ ```
44
+
45
+ Upload files from the source machine:
46
+
47
+ ```bash
48
+ mstransfer upload /data/experiment1.mzML /data/batch/ remote-host:1319
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ ### `mstransfer serve`
54
+
55
+ Start the receiver server.
56
+
57
+ ```
58
+ mstransfer serve [--host 0.0.0.0] [--port 1319] [--output-dir ./received] [--store-as msz|mzml]
59
+ ```
60
+
61
+ | Flag | Default | Description |
62
+ |------|---------|-------------|
63
+ | `--host` | `0.0.0.0` | Bind address |
64
+ | `--port` | `1319` | Listen port |
65
+ | `--output-dir` | `./received` | Where received files are written |
66
+ | `--store-as` | `msz` | Store as `msz` (compressed) or `mzml` (decompress on arrival) |
67
+
68
+ ### `mstransfer upload`
69
+
70
+ Upload files to a server. Accepts any mix of files and directories. The last positional argument is the target.
71
+
72
+ ```
73
+ mstransfer upload <paths...> <host[:port]> [--recursive] [--parallel 4]
74
+ ```
75
+
76
+ | Flag | Default | Description |
77
+ |------|---------|-------------|
78
+ | `--recursive`, `-r` | off | Recurse into directories |
79
+ | `--parallel`, `-p` | `4` | Number of concurrent uploads |
80
+
81
+ Supported file types: `.mzML`, `.msz`, `.mszx`.
82
+
83
+ - **mzML files** are compressed to MSZ on-the-fly via `compress_stream()` and streamed directly into the HTTP request — no temp files on the sender.
84
+ - **MSZ / MSZX files** are streamed as-is.
85
+
86
+ ## Programmatic access
87
+
88
+ You can use mstransfer as a library to send files from your own Python code:
89
+
90
+ ```python
91
+ from pathlib import Path
92
+ from mstransfer.client import send_file, send_batch
93
+
94
+ # Send a single file (Path)
95
+ result = send_file(Path("experiment.mzML"), "http://remote-host:1319")
96
+
97
+ # Send an already-opened mscompress object
98
+ from mscompress import MZMLFile, MSZFile
99
+ from mscompress.mszx import MSZXFile
100
+
101
+ mzml = MZMLFile(b"/data/experiment.mzML")
102
+ send_file(mzml, "http://remote-host:1319")
103
+
104
+ msz = MSZFile(b"/data/experiment.msz")
105
+ send_file(msz, "http://remote-host:1319")
106
+
107
+ mszx = MSZXFile.open("/data/experiment.mszx")
108
+ send_file(mszx, "http://remote-host:1319")
109
+
110
+ # Send multiple files in parallel
111
+ send_batch(
112
+ [Path("a.mzML"), Path("b.msz"), mszx],
113
+ "http://remote-host:1319",
114
+ parallel=4,
115
+ )
116
+ ```
117
+
118
+ `send_file` and `send_batch` accept any mix of `Path`, `MZMLFile`, `MSZFile`, and `MSZXFile` inputs.
119
+
120
+ ## API
121
+
122
+ The server exposes a REST API under `/v1/`:
123
+
124
+ | Endpoint | Method | Description |
125
+ |----------|--------|-------------|
126
+ | `/v1/health` | GET | Server status, version, storage mode |
127
+ | `/v1/upload` | POST | Upload a file (streamed MSZ body) |
128
+ | `/v1/transfer/{id}/status` | GET | Poll transfer state |
129
+
130
+ ### Embedding in another app
131
+
132
+ The server is built as a FastAPI app factory:
133
+
134
+ ```python
135
+ from mstransfer import create_app
136
+
137
+ # Standalone
138
+ app = create_app(output_dir="/data/ms", store_as="mzml")
139
+
140
+ # Mount in an existing FastAPI app
141
+ from fastapi import FastAPI
142
+ main_app = FastAPI()
143
+ main_app.mount("/transfer", create_app())
144
+ ```
145
+
146
+ ## How it works
147
+
148
+ ```mermaid
149
+ flowchart LR
150
+ subgraph Sender
151
+ mzML[".mzML"] --> compress["compress_stream()"]
152
+ msz[".msz / .mszx"] --> read["read file"]
153
+ end
154
+
155
+ compress --> upload["POST /v1/upload\n(MSZ bytes)"]
156
+ read --> upload
157
+
158
+ subgraph Server
159
+ upload --> mode{store-as?}
160
+ mode -- msz --> write["write to disk"]
161
+ mode -- mzml --> temp["write temp .msz"]
162
+ temp --> decompress["decompress"]
163
+ decompress --> cleanup["cleanup temp"]
164
+ end
165
+ ```
166
+
167
+ ## Development
168
+
169
+ ```bash
170
+ uv sync --dev
171
+ uv run pytest
172
+ uv run ruff check src/ tests/
173
+ ```
@@ -0,0 +1,158 @@
1
+ # mstransfer
2
+
3
+ [![Tests](https://github.com/chrisagrams/mstransfer/actions/workflows/test.yml/badge.svg)](https://github.com/chrisagrams/mstransfer/actions/workflows/test.yml)
4
+ [![codecov](https://codecov.io/gh/chrisagrams/mstransfer/graph/badge.svg)](https://codecov.io/gh/chrisagrams/mstransfer)
5
+
6
+ Transfer mass spectrometry files (mzML / MSZ) between machines over HTTP. Files are always transported in compressed MSZ format using [mscompress](https://github.com/chrisagrams/mscompress) — mzML sources are compressed on-the-fly without temp files, and the receiving end can optionally decompress back to mzML.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ # Recommended — installs as an isolated CLI tool
12
+ uv tool install mstransfer
13
+
14
+ # Or with pipx
15
+ pipx install mstransfer
16
+
17
+ # Or as a project dependency
18
+ uv pip install mstransfer
19
+ pip install mstransfer
20
+ ```
21
+
22
+ ## Quick start
23
+
24
+ Start a server on the receiving machine:
25
+
26
+ ```bash
27
+ mstransfer serve --port 1319 --store-as msz
28
+ ```
29
+
30
+ Upload files from the source machine:
31
+
32
+ ```bash
33
+ mstransfer upload /data/experiment1.mzML /data/batch/ remote-host:1319
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ ### `mstransfer serve`
39
+
40
+ Start the receiver server.
41
+
42
+ ```
43
+ mstransfer serve [--host 0.0.0.0] [--port 1319] [--output-dir ./received] [--store-as msz|mzml]
44
+ ```
45
+
46
+ | Flag | Default | Description |
47
+ |------|---------|-------------|
48
+ | `--host` | `0.0.0.0` | Bind address |
49
+ | `--port` | `1319` | Listen port |
50
+ | `--output-dir` | `./received` | Where received files are written |
51
+ | `--store-as` | `msz` | Store as `msz` (compressed) or `mzml` (decompress on arrival) |
52
+
53
+ ### `mstransfer upload`
54
+
55
+ Upload files to a server. Accepts any mix of files and directories. The last positional argument is the target.
56
+
57
+ ```
58
+ mstransfer upload <paths...> <host[:port]> [--recursive] [--parallel 4]
59
+ ```
60
+
61
+ | Flag | Default | Description |
62
+ |------|---------|-------------|
63
+ | `--recursive`, `-r` | off | Recurse into directories |
64
+ | `--parallel`, `-p` | `4` | Number of concurrent uploads |
65
+
66
+ Supported file types: `.mzML`, `.msz`, `.mszx`.
67
+
68
+ - **mzML files** are compressed to MSZ on-the-fly via `compress_stream()` and streamed directly into the HTTP request — no temp files on the sender.
69
+ - **MSZ / MSZX files** are streamed as-is.
70
+
71
+ ## Programmatic access
72
+
73
+ You can use mstransfer as a library to send files from your own Python code:
74
+
75
+ ```python
76
+ from pathlib import Path
77
+ from mstransfer.client import send_file, send_batch
78
+
79
+ # Send a single file (Path)
80
+ result = send_file(Path("experiment.mzML"), "http://remote-host:1319")
81
+
82
+ # Send an already-opened mscompress object
83
+ from mscompress import MZMLFile, MSZFile
84
+ from mscompress.mszx import MSZXFile
85
+
86
+ mzml = MZMLFile(b"/data/experiment.mzML")
87
+ send_file(mzml, "http://remote-host:1319")
88
+
89
+ msz = MSZFile(b"/data/experiment.msz")
90
+ send_file(msz, "http://remote-host:1319")
91
+
92
+ mszx = MSZXFile.open("/data/experiment.mszx")
93
+ send_file(mszx, "http://remote-host:1319")
94
+
95
+ # Send multiple files in parallel
96
+ send_batch(
97
+ [Path("a.mzML"), Path("b.msz"), mszx],
98
+ "http://remote-host:1319",
99
+ parallel=4,
100
+ )
101
+ ```
102
+
103
+ `send_file` and `send_batch` accept any mix of `Path`, `MZMLFile`, `MSZFile`, and `MSZXFile` inputs.
104
+
105
+ ## API
106
+
107
+ The server exposes a REST API under `/v1/`:
108
+
109
+ | Endpoint | Method | Description |
110
+ |----------|--------|-------------|
111
+ | `/v1/health` | GET | Server status, version, storage mode |
112
+ | `/v1/upload` | POST | Upload a file (streamed MSZ body) |
113
+ | `/v1/transfer/{id}/status` | GET | Poll transfer state |
114
+
115
+ ### Embedding in another app
116
+
117
+ The server is built as a FastAPI app factory:
118
+
119
+ ```python
120
+ from mstransfer import create_app
121
+
122
+ # Standalone
123
+ app = create_app(output_dir="/data/ms", store_as="mzml")
124
+
125
+ # Mount in an existing FastAPI app
126
+ from fastapi import FastAPI
127
+ main_app = FastAPI()
128
+ main_app.mount("/transfer", create_app())
129
+ ```
130
+
131
+ ## How it works
132
+
133
+ ```mermaid
134
+ flowchart LR
135
+ subgraph Sender
136
+ mzML[".mzML"] --> compress["compress_stream()"]
137
+ msz[".msz / .mszx"] --> read["read file"]
138
+ end
139
+
140
+ compress --> upload["POST /v1/upload\n(MSZ bytes)"]
141
+ read --> upload
142
+
143
+ subgraph Server
144
+ upload --> mode{store-as?}
145
+ mode -- msz --> write["write to disk"]
146
+ mode -- mzml --> temp["write temp .msz"]
147
+ temp --> decompress["decompress"]
148
+ decompress --> cleanup["cleanup temp"]
149
+ end
150
+ ```
151
+
152
+ ## Development
153
+
154
+ ```bash
155
+ uv sync --dev
156
+ uv run pytest
157
+ uv run ruff check src/ tests/
158
+ ```
@@ -0,0 +1,44 @@
1
+ [project]
2
+ name = "mstransfer"
3
+ version = "0.1.0"
4
+ description = "Transfer mass spectrometry files (mzML/MSZ) between endpoints using mscompress"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "mscompress",
9
+ "fastapi",
10
+ "uvicorn[standard]",
11
+ "httpx",
12
+ "rich",
13
+ "python-multipart",
14
+ "pydantic>=2.0",
15
+ "aiofiles",
16
+ ]
17
+
18
+ [project.scripts]
19
+ mstransfer = "mstransfer.cli:main"
20
+
21
+ [build-system]
22
+ requires = ["hatchling"]
23
+ build-backend = "hatchling.build"
24
+
25
+ [tool.hatch.build.targets.wheel]
26
+ packages = ["src/mstransfer"]
27
+
28
+ [tool.ruff]
29
+ target-version = "py310"
30
+ line-length = 88
31
+
32
+ [tool.ruff.lint]
33
+ select = ["E", "F", "W", "I", "N", "UP", "B", "A", "SIM", "TCH", "PLC0415"]
34
+
35
+ [dependency-groups]
36
+ dev = [
37
+ "pytest",
38
+ "pytest-asyncio",
39
+ "pytest-cov",
40
+ "httpx",
41
+ "ruff",
42
+ "pre-commit",
43
+ "pyright>=1.1.408",
44
+ ]
@@ -0,0 +1,7 @@
1
+ """mstransfer — Transfer mass spectrometry files between endpoints."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+ from mstransfer.server.app import create_app
6
+
7
+ __all__ = ["__version__", "create_app"]
@@ -0,0 +1,3 @@
1
+ from mstransfer.cli import main
2
+
3
+ main()