Skip to content

Commit 442120f

Browse files
authored
Merge branch 'main' into dependabot/github_actions/actions-rs/toolchain-1.0.7
2 parents 3a18be2 + c3bcebe commit 442120f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+10559
-4157
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
version: 2
22
updates:
3-
- package-ecosystem: cargo
4-
directory: "/"
5-
schedule:
6-
interval: monthly
7-
time: "13:00"
8-
open-pull-requests-limit: 10
9-
commit-message:
10-
prefix: "chore: "
11-
allow:
12-
- dependency-type: "direct"
3+
# Generates far too much PR noise
4+
# - package-ecosystem: cargo
5+
# directory: "/"
6+
# schedule:
7+
# interval: monthly
8+
# time: "13:00"
9+
# open-pull-requests-limit: 10
10+
# commit-message:
11+
# prefix: "chore: "
12+
# allow:
13+
# - dependency-type: "direct"
1314
- package-ecosystem: github-actions
1415
directory: "/"
1516
schedule:

.github/workflows/python.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
on:
2+
push:
3+
branches: [main, dev]
4+
pull_request:
5+
6+
name: Python data round trips
7+
8+
jobs:
9+
test-metadata:
10+
name: Test Python metadata round trips
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-24.04]
15+
rust:
16+
- stable
17+
python: [ "3.13" ]
18+
steps:
19+
- name: Cancel Previous Runs
20+
uses: styfle/[email protected]
21+
with:
22+
access_token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- uses: actions/[email protected]
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
submodules: recursive
28+
- uses: dtolnay/rust-toolchain@v1
29+
with:
30+
toolchain: ${{ matrix.rust }}
31+
- uses: Swatinem/[email protected]
32+
- name: Install the latest version of uv
33+
uses: astral-sh/setup-uv@v6
34+
with:
35+
activate-environment: true
36+
version: "latest"
37+
python-version: ${{ matrix.python }}
38+
- name: run JSON metadata example
39+
run: |
40+
cargo run --example json_metadata --features derive
41+
- name: run bincode metadata example
42+
run: |
43+
cargo run --example bincode_metadata --features derive
44+
- name: setup Python and run tests
45+
run: |
46+
uv venv -p ${{ matrix.python }}
47+
source .venv/bin/activate
48+
uv pip install -r python/requirements_locked_3_13.txt
49+
uv pip install python/tskit_glue
50+
python -m pytest python
51+

.github/workflows/semver.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ jobs:
2020
toolchain: ${{ matrix.rust }}
2121
components: clippy
2222
- name: Install cargo-semver-checks
23-
uses: baptiste0928/cargo-install@v3.1.1
23+
uses: baptiste0928/cargo-install@v3.3.2
2424
with:
2525
crate: cargo-semver-checks
26+
version: '0.43.0'
2627
- name: run check-release
27-
run: cargo semver-checks check-release
28+
# We set the cargo version here to dodge ecosystem
29+
# issues that can arise b/c semver-checks doesnt'
30+
# respect our Cargo.lock
31+
run: cargo +1.90.0 semver-checks check-release

.github/workflows/test32bit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
- name: Install rust tooling for 32 bit builds
3939
run: |
4040
rustup target install i686-unknown-linux-gnu
41+
- name: Install rust toolchain
42+
run: |
43+
rustup toolchain install
4144
- name: cargo check
4245
run: |
4346
cargo hack check --all-targets --target=i686-unknown-linux-gnu --feature-powerset

.github/workflows/tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333
- uses: taiki-e/install-action@cargo-hack
3434
- run: sudo apt-get update -y
3535
if: matrix.os == 'ubuntu-24.04'
36+
- name: update toolchain
37+
run: rustup toolchain install
3638
- name: cargo check (powerset)
3739
run: cargo hack check --feature-powerset --no-dev-deps
3840
- name: cargo check examples (powerset)
@@ -74,6 +76,8 @@ jobs:
7476
components: clippy
7577
- uses: Swatinem/[email protected]
7678
- uses: taiki-e/install-action@cargo-hack
79+
- name: update toolchain
80+
run: rustup toolchain install
7781
- name: clippy (all targets, feature powerset)
7882
run: cargo hack clippy --all-targets --feature-powerset -- -D warnings
7983

@@ -83,7 +87,7 @@ jobs:
8387
strategy:
8488
matrix:
8589
rust:
86-
- 1.71.0
90+
- 1.75.0
8791
steps:
8892
- uses: actions/[email protected]
8993
- uses: dtolnay/rust-toolchain@v1

Cargo.lock

Lines changed: 0 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description = "rust interface to tskit"
88
license = "MIT"
99
homepage = "https://github.com/tskit-dev/tskit-rust"
1010
repository = "https://github.com/tskit-dev/tskit-rust"
11-
rust-version = "1.71.0"
11+
rust-version = "1.75.0"
1212

1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414
[lints.rust]
@@ -20,7 +20,6 @@ lto = "fat"
2020
codegen-units=1
2121

2222
[dependencies]
23-
thiserror = "1.0"
2423
libc = "0.2.155"
2524
streaming-iterator = "0.1.5"
2625
serde = {version = "1.0.203", features = ["derive"], optional = true}
@@ -56,3 +55,14 @@ rustdoc-args = ["--cfg", "doc_cfg"]
5655
# Not run during tests
5756
[[example]]
5857
name = "tree_traversals"
58+
59+
[[example]]
60+
name = "json_metadata"
61+
required-features = ["derive"]
62+
63+
[[example]]
64+
name = "bincode_metadata"
65+
required-features = ["derive"]
66+
67+
[[example]]
68+
name = "manual_metadata_encoding"

book/src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* [Metadata](./metadata.md)
2020
- [Defining metadata types in rust](./metadata_derive.md)
2121
- [Metadata and tables](./metadata_tables.md)
22-
- [Metadata schema](./metadata_schema.md)
22+
- [Metadata processing with Python](./metadata_python.md)
2323
- [Advanced topics](./metadata_advanced.md)
2424

2525
* [Error handling](./error_handling.md)

book/src/metadata_python.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Metadata processing with Python
2+
3+
## `JSON` metadata
4+
5+
If your metadata are generated in `JSON` format via `serde` (see [here](metadata_derive.md)), then the metadata are simple to access from Python.
6+
The code repository for `tskit-rust` contains examples in the `python/` subdirectory.
7+
8+
You may work with `JSON` metadata with or without a metadata schema (see [here](https://tskit.dev/tskit/docs/stable/metadata.html)).
9+
A schema is useful for data validation but there is an unfortunate inefficiency if your input to Python is a tree sequence rather than a table collection.
10+
You will have to copy the tables, add the metadata schema, and regenerate a tree sequence.
11+
See the examples mentioned above.
12+
13+
## Other formats
14+
15+
The `tskit-python` API only supports `JSON` and Python's `struct` data formats.
16+
It is useful to use a format other than `JSON` in order to minimize storage requirements.
17+
However, doing so will require that you provide a method to covert the data into a valid Python object.
18+
19+
An easy way to provide conversion methods is to use [pyo3](https://pyo3.rs) to create a small Python module to deserialize your metadata into Python objects.
20+
The `tskit-rust` code repository contains an example of this in the `python/` subdirectory.
21+
The module is shown in its entirety below:
22+
23+
```rust, noplaygound, ignore
24+
{{#include ../../python/tskit_glue/src/lib.rs}}
25+
```
26+
27+
Using it in Python is just a matter of importing the module:
28+
29+
```python
30+
{{#include ../../python/test_bincode_metadata.py}}
31+
```

book/src/metadata_schema.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)