Skip to content

Rust bindings (mir-sys crate) - #49

Open
Choochmeque wants to merge 25 commits into
developfrom
rust-bindings
Open

Rust bindings (mir-sys crate)#49
Choochmeque wants to merge 25 commits into
developfrom
rust-bindings

Conversation

@Choochmeque

@Choochmeque Choochmeque commented May 6, 2026

Copy link
Copy Markdown

Description

Full implementation of the -sys crate for mir

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

@codecov-commenter

codecov-commenter commented May 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.39%. Comparing base (0ef8096) to head (670ce1a).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop      #49   +/-   ##
========================================
  Coverage    56.39%   56.39%           
========================================
  Files          620      620           
  Lines        25891    25891           
  Branches      2279     2279           
========================================
  Hits         14601    14601           
  Misses       11290    11290           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pmaciel

pmaciel commented Jun 21, 2026

Copy link
Copy Markdown
Member

Hi @Choochmeque, can you book a meeting to discuss this? Thanks!

@Choochmeque
Choochmeque marked this pull request as ready for review August 24, 2026 11:28
@Choochmeque
Choochmeque requested a review from pmaciel August 24, 2026 11:28

@pmaciel pmaciel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remarks:

  • can you add headers to every added source file (.h, .cc, .rs, .toml), similar to the C++ sources (like MIRJob.h and others); we have adopted SPDX headers but haven't transitioned yet
  • style:
    • can you remove lines like //-------------------------...
    • two empty lines between: license, headers/pre-processor directives, namespace opening/closing, code propper (class declarations, methods implementation, etc.)
    • remove functionality related to mir_tool_call, representation_from (we're transitioning out of this)
    • rename the create... methods with make... (this is for consistency with the python bindings)

I don't see that this bindings makes optional use of metkit (but, it's also fine like this.)

It also is disabling tests, which might be part of an implicit contract that these are to be built separately from a main build that actually tests, and stops if tests fail? It is missing tests and/or examples, which are extremely valuable as a high-level documentation or starting points for a newcomer -- specifically the processing of GRIB messages to/from memory are extremely valuable. A unit test and a (small) Jupyter notebook at least?

Note that when I mean "I don't like" or "I prefer" it really is just personal preference and no criticism, just a point of discussion that might sway to a compromise we'd both be happy with!

@@ -0,0 +1,90 @@
// mir job bridge — implementation.
#include "Job.h"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

header order should be (separate groups with empty line):

  • class declaration (correct for this one)
  • c headers
  • c++ headers
  • upstream projects first (eckit, eccodes, atlas, metkit, in this order)
  • system/platform headers if needed

Always prefix the headers with relative to project root (so the hierarchy is immediately visible)

Comment thread rust/crates/mir-sys/cpp/Job.h Outdated
@@ -0,0 +1,70 @@
// mir job bridge — wraps `mir::api::MIRJob`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These comments aren't necessary (I'm being pedantic)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in a901981

Comment thread rust/crates/mir-sys/cpp/Job.h Outdated

//----------------------------------------------------------------------------------------------------------------------

/// A description of the transformation to apply, not the transformation itself:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I prefer long comments using the block version (/* /, or in this case /* */). Since you're refering to reusing MIRJob, also document that the input (MIRInput argument) is consumed with next()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in edc850b

#include <string>
#include <vector>

namespace mir_bridge {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Discussion only frst - is "bridge" the terminology? I would prefer bindings documentation-wise -- the c++ namespace should really be mir::rust (not bindings not bridge)

@Choochmeque Choochmeque Aug 25, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

"bridge" is just a name - happy to go with mir::rust.

Comment thread rust/crates/mir-sys/cpp/LibMir.h Outdated

//----------------------------------------------------------------------------------------------------------------------

/// Static accessors for the mir library itself. Holds no state; it exists as a

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This comment says 3 times the same thing

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in a901981

/// base — only a subclass can render the contents. The setters shadow inherited
/// overloads purely so Rust passes `&str` and `&[i64]` instead of building
/// `CxxString` and `CxxVector` at every call site.
class Parametrisation final : public mir::param::SimpleParametrisation {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The bindings's Parametrisation are the c++'s SimpleParametrisation. Good change because "Simple" is not a great name and we don't want that to leak. In an eckit module, I refer to this kind as "Custom" (as in, a custom, user-driven parametrisation). What do you think?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Do you mean rename class Parametrisation to Custom? Because SimpleParametrisation will not leak to rust anyway.

"-DCMAKE_BUILD_TYPE={}",
bindman_utils::cmake_build_type()
))
.arg("-DENABLE_TESTS=OFF")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't like this -- why?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

cargo builds mir only to link it, and never runs mir's C++ tests, so building them just adds time.

Comment thread rust/crates/mir-sys/Cargo.toml Outdated
@@ -0,0 +1,53 @@
[package]
name = "mir-sys"
version = "1.28.2"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can this be made dynamic? We are already ahead of this, and with a planned 2.0 release this year, or early next year

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in cdfa37b

Comment thread rust/crates/mir-sys/Cargo.toml Outdated
"eckit-sys/eckit-spec",
"eckit-sys/eckit-geo",
"eckit-sys/geo-codec-grids",
"metkit-sys/vendored",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In our stacks we build metkit after atlas/before mir, maybe this order should generally be reflected here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in b8dde12

Comment thread rust/crates/mir-sys/README.md Outdated
@@ -0,0 +1,18 @@
# mir-sys

Low-level Rust bindings to ECMWF's [mir](https://github.com/ecmwf/mir) (Meteorological Interpolation and Regridding) C++ library.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove Low-level

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 69ab838

…Output, and Parametrisation files for cleaner code.
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