Skip to content

Fix compilation errors from merge conflict in resource versioning#127

Merged
fbkaragoz merged 4 commits into
feature/25-resource-versioningfrom
copilot/sub-pr-27-again
Jan 31, 2026
Merged

Fix compilation errors from merge conflict in resource versioning#127
fbkaragoz merged 4 commits into
feature/25-resource-versioningfrom
copilot/sub-pr-27-again

Conversation

Copilot AI commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

Merge commit 0cbc51e lost ResourceMetadata, ResourceInfo, and their associated functions (get_build_info, get_resource_info) but retained module registration references, causing compilation failures.

Changes

  • Restored missing code from commit 3f66674:

    • ResourceMetadata and ResourceInfo structs with serde derives
    • get_build_info() and get_resource_info() Python bindings
  • Fixed type handling:

    • Return Py<PyAny> instead of deprecated PyObject
    • Return item_count as int instead of string for Python interop
  • Added robustness:

    • Use option_env!() with fallback for CARGO_PKG_RUST_VERSION
    • Added rust-version = "1.70" to Cargo.toml

Example Usage

from durak import get_build_info, get_resource_info

# Build metadata now accessible
info = get_build_info()
# {'durak_version': '0.4.0', 'rust_version': '1.70', ...}

# Resource checksums with proper types
resources = get_resource_info()
assert isinstance(resources['stopwords_base']['item_count'], int)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 28, 2026 09:54
Restored missing ResourceMetadata and ResourceInfo structs and get_build_info/get_resource_info functions that were lost during merge. Fixed return types to properly handle mixed Python types.

Co-authored-by: fbkaragoz <59958216+fbkaragoz@users.noreply.github.com>
Replace deprecated pyo3::PyObject with Py<pyo3::types::PyAny> to comply with current PyO3 API

Co-authored-by: fbkaragoz <59958216+fbkaragoz@users.noreply.github.com>
Replace env! with option_env! for CARGO_PKG_RUST_VERSION to handle cases where rust-version field is not set in Cargo.toml, improving robustness

Co-authored-by: fbkaragoz <59958216+fbkaragoz@users.noreply.github.com>
Copilot AI changed the title [WIP] Add resource versioning and reproducibility tracking Fix compilation errors from merge conflict in resource versioning Jan 28, 2026
Copilot AI requested a review from fbkaragoz January 28, 2026 10:02
@fbkaragoz fbkaragoz marked this pull request as ready for review January 31, 2026 22:17
Copilot AI review requested due to automatic review settings January 31, 2026 22:18
@fbkaragoz fbkaragoz merged commit 07ad370 into feature/25-resource-versioning Jan 31, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores the resource metadata and versioning bindings that were accidentally dropped in a previous merge, and aligns the crate with a minimum Rust version. It reintroduces the Rust structures and Python-facing functions needed to inspect build metadata and embedded resources, and updates configuration/dependencies accordingly.

Changes:

  • Reintroduced ResourceInfo/ResourceMetadata structs and the get_build_info and get_resource_info Python bindings in src/lib.rs, wired into the PyO3 module.
  • Ensured build metadata is robust by reading CARGO_PKG_RUST_VERSION via option_env! with a "1.70" fallback and by parsing embedded resources/metadata.json.
  • Declared rust-version = "1.70" in Cargo.toml and updated Cargo.lock to include serde/serde_json and their transitive dependencies.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/lib.rs Restores resource metadata structs and Python APIs, parses embedded RESOURCE_METADATA, and registers the new functions in the PyO3 module.
Cargo.toml Sets the crate’s minimum supported Rust version to 1.70 to match the metadata reported by get_build_info.
Cargo.lock Updates lockfile to include serde, serde_json, and related dependencies needed for the new metadata parsing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib.rs
Comment on lines +338 to +339
let metadata: ResourceMetadata = serde_json::from_str(RESOURCE_METADATA)
.expect("Failed to parse embedded resource metadata");

Copilot AI Jan 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using expect on serde_json::from_str(RESOURCE_METADATA) inside a #[pyfunction] will turn JSON parse failures into a Rust panic, which surfaces to Python as a less-informative error and can impact reliability; it would be safer to map the parse error into a PyErr (e.g., returning a Python exception) rather than panicking.

Copilot uses AI. Check for mistakes.
Comment thread src/lib.rs
/// print(resources['stopwords_base']['item_count']) # 442
/// ```
#[pyfunction]
fn get_resource_info(py: Python) -> PyResult<HashMap<String, Py<pyo3::types::PyAny>>> {

Copilot AI Jan 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_build_info/get_resource_info introduce new observable behavior but there are no unit tests covering them, while this file already has tests for other core functions; consider adding tests that exercise their happy-path behavior (e.g., keys present, item_count type) and failure modes (e.g., malformed RESOURCE_METADATA).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants