Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PythonObjectCache to support get and pop operations, update utils to allow passing of cached python objects. #417

Open
wants to merge 4 commits into
base: branch-24.06
Choose a base branch
from

Conversation

drobison00
Copy link
Contributor

Description

Update PythonObjectCache to support get and pop operations, update utils to allow passing of cached python objects.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@drobison00 drobison00 requested a review from a team as a code owner December 4, 2023 22:57
rapids-bot bot pushed a commit that referenced this pull request Apr 3, 2024
… possible, and as pybind11::object otherwise (#455)

* Add an optional `unserializable_handler_fn` callback to `mrc::pymrc::cast_from_pyobject` which will be invoked for any unsupported Python object. Allowing for serializing unsupported object.
ex:
```cpp
    pymrc::unserializable_handler_fn_t handler_fn = [](const py::object& source,
                                                       const std::string& path) {
        return nlohmann::json(py::cast<float>(source));
    };

    // decimal.Decimal is not serializable
    py::object Decimal = py::module_::import("decimal").attr("Decimal");
    py::object o       = Decimal("1.0");
    EXPECT_EQ(pymrc::cast_from_pyobject(o, handler_fn), nlohmann::json(1.0));
```

* Add `JSONValues` container class which is an immutable container for holding Python values as `nlohmann::json` objects if possible, and as `pybind11::object` otherwise. The container can be copied and moved, but the underlying `nlohmann::json` object is immutable.
* Updates `nlohmann_json` from 3.9 to 3.11 for `patch_inplace` method.
* Incorporates ideas from @drobison00's PR #417 with three key differences:

  1. Changes to the `cast_from_pyobject` are opt-in when `unserializable_handler_fn` is provided, otherwise there is no behavior change to the method.
  2. Unserializable objects are stored in `JSONValues` rather than a global cache.
  3. Does not rely on parsing the place-holder values.

This PR is related to nv-morpheus/Morpheus#1560

Authors:
  - David Gardner (https://github.com/dagardner-nv)
  - Devin Robison (https://github.com/drobison00)

Approvers:
  - Michael Demoret (https://github.com/mdemoret-nv)

URL: #455
@mdemoret-nv mdemoret-nv changed the base branch from branch-24.03 to branch-24.06 April 6, 2024 00:12
Copy link

codecov bot commented Oct 21, 2024

Codecov Report

Attention: Patch coverage is 14.70588% with 29 lines in your changes missing coverage. Please review.

Project coverage is 51.98%. Comparing base (b152175) to head (5b2265e).
Report is 40 commits behind head on branch-24.06.

Files with missing lines Patch % Lines
python/mrc/_pymrc/src/utilities/object_cache.cpp 0.00% 18 Missing ⚠️
python/mrc/_pymrc/src/utils.cpp 31.25% 11 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                @@
##           branch-24.06     #417       +/-   ##
=================================================
- Coverage         74.00%   51.98%   -22.03%     
=================================================
  Files               394      357       -37     
  Lines             13955    11492     -2463     
  Branches           1054      970       -84     
=================================================
- Hits              10328     5974     -4354     
- Misses             3627     5518     +1891     
Flag Coverage Δ
cpp 45.32% <14.70%> (-25.16%) ⬇️
py 42.52% <14.70%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...rc/_pymrc/include/pymrc/utilities/object_cache.hpp 0.00% <ø> (ø)
python/mrc/_pymrc/src/segment.cpp 82.11% <ø> (ø)
python/mrc/_pymrc/src/utils.cpp 72.50% <31.25%> (-9.32%) ⬇️
python/mrc/_pymrc/src/utilities/object_cache.cpp 57.57% <0.00%> (-21.60%) ⬇️

... and 168 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b152175...5b2265e. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Review - Ready for Review
Development

Successfully merging this pull request may close these issues.

1 participant