Skip to content

Python interface improvements for GroundStation#548

Open
ChristopherRabotin wants to merge 9 commits into
feat/md-od-python-gh-540from
python-ground-station-constructor-2480680211005972602
Open

Python interface improvements for GroundStation#548
ChristopherRabotin wants to merge 9 commits into
feat/md-od-python-gh-540from
python-ground-station-constructor-2480680211005972602

Conversation

@ChristopherRabotin

Copy link
Copy Markdown
Member

This patch introduces a robust __new__ Python constructor for GroundStation through pyo3, with full field configuration capabilities. In addition, it implements Python-native serialization and deserialization via classmethods and object methods, namely: from_yaml, to_yaml, from_dhall, to_dhall, load_many_yaml, loads_many_yaml, dump_many_yaml, and dumps_many_yaml. This fulfills the user request of allowing full construction and multpile-station YAML/Dhall I/O from Python.


PR created automatically by Jules for task 2480680211005972602 started by @ChristopherRabotin

…zation

Co-authored-by: ChristopherRabotin <4823784+ChristopherRabotin@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces Python bindings for the GroundStation struct under the python feature flag, including serialization and deserialization capabilities for Dhall and YAML formats. The review feedback identifies a compilation error in the Dhall parsing method, redundant conditional compilation attributes, and opportunities to simplify the constructor implementation.

Comment on lines +52 to +56
fn py_from_dhall(_cls: &Bound<'_, pyo3::types::PyType>, dhall_str: &str) -> PyResult<Self> {
serde_dhall::from_str(dhall_str)
.parse()
.map_err(|e| pyo3::exceptions::PyValueError::new_err(e.to_string()))
}

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.

critical

serde_dhall::from_str returns a Result<Parsed, Error>. Calling .parse() directly on a Result is a compilation error. Instead, use .and_then(|parsed| parsed.parse()) to parse the inner value.

Suggested change
fn py_from_dhall(_cls: &Bound<'_, pyo3::types::PyType>, dhall_str: &str) -> PyResult<Self> {
serde_dhall::from_str(dhall_str)
.parse()
.map_err(|e| pyo3::exceptions::PyValueError::new_err(e.to_string()))
}
fn py_from_dhall(_cls: &Bound<'_, pyo3::types::PyType>, dhall_str: &str) -> PyResult<Self> {
serde_dhall::from_str(dhall_str)
.and_then(|parsed| parsed.parse())
.map_err(|e| pyo3::exceptions::PyValueError::new_err(e.to_string()))
}

Comment on lines +1 to +17
#[cfg(feature = "python")]
use super::GroundStation;
#[cfg(feature = "python")]
use pyo3::prelude::*;
#[cfg(feature = "python")]
use anise::astro::Location;
#[cfg(feature = "python")]
use indexmap::{IndexSet, IndexMap};
#[cfg(feature = "python")]
use super::super::msr::MeasurementType;
#[cfg(feature = "python")]
use super::super::noise::StochasticNoise;
#[cfg(feature = "python")]
use hifitime::Duration;

#[cfg(feature = "python")]
#[pymethods]

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.

medium

Since the entire python module is conditionally compiled via #[cfg(feature = "python")] pub mod python; in mod.rs, these individual #[cfg(feature = "python")] attributes on every import and the impl block are redundant and clutter the code. They can be safely removed to improve readability.

use super::GroundStation;
use pyo3::prelude::*;
use anise::astro::Location;
use indexmap::{IndexSet, IndexMap};
use super::super::msr::MeasurementType;
use super::super::noise::StochasticNoise;
use hifitime::Duration;

#[pymethods]
impl GroundStation {

Comment thread nyx-core/src/od/ground_station/python.rs
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 3b07c6a):

https://nyx-rustdoc--pr548-python-ground-statio-45pth7ol.web.app

(expires Mon, 15 Jun 2026 21:34:18 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: d8e2a55934352d850c15d11866c39eb2d2e029be

@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.37500% with 13 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (feat/md-od-python-gh-540@80e4580). Learn more about missing BASE report.

Files with missing lines Patch % Lines
nyx-core/src/md/trajectory/traj.rs 57.14% 12 Missing ⚠️
nyx-core/src/od/ground_station/mod.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                     @@
##             feat/md-od-python-gh-540     #548   +/-   ##
===========================================================
  Coverage                            ?   77.97%           
===========================================================
  Files                               ?      103           
  Lines                               ?    16661           
  Branches                            ?        0           
===========================================================
  Hits                                ?    12991           
  Misses                              ?     3670           
  Partials                            ?        0           

☔ View full report in Codecov by Harness.
📢 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.

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.

1 participant