Skip to content

Python bindings are non-functional #296

@olepbr

Description

@olepbr

The Python bindings, merged in #184, are non-functional. Some immediate issues:

  • get_energy_consumption_measures() does not actually return any consumption measures; it returns an empty list. This is because it just calls generate_topology() and iterates over the generated Topology's record_buffer, which is empty as the topology was just generated (Topology::new() does record_buffer =vec![]).
  • The PR claimed to add Python documentation, but it merely added an empty Sphinx harness.
  • The supplied Makefile does not work as intended: make install fails due to $(eval TARGET_WHEEL := $(shell ls ../target/wheels/scaphandre-${PACKAGE_VERSION}-*.whl)) looking for the wheel in the parent directory's target/ instead of its own target/, where maturin build was just run.
  • Even the string representation of the class is broken: from scaphandre import Scaphandre; s = Scaphandre(); print(s); results in AttributeError, because the dataclass (which includes all fields in the generated __repr__() unless one specifies repr=False) is defined with sensor_name: str whilst the __init__() sets self.name.
  • Furthermore, the bindings deviate from Scaphandre itself: why is the sensor called _scaphandre instead of sensor, for instance? Given that these are "official" bindings, I think they should have a structure similar to the Rust implementation, or at least be more clearly defined and documented.

I guess all of this ties in with #50; since it's not clear how to use Scaphandre as a Rust crate, making bindings to another language is potentially even less clear. Most of these issues are easily fixable, though, but I do question why these bindings were merged in the first place.

Anyway, I hope this is of help. :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Previous releases

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions