Skip to content

Commit

Permalink
fix styles
Browse files Browse the repository at this point in the history
  • Loading branch information
cwharris committed Oct 24, 2023
1 parent 2b2363e commit 5a807f6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
8 changes: 5 additions & 3 deletions python/mrc/_pymrc/include/pymrc/coro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
#include <pybind11/pytypes.h>
#include <pymrc/types.hpp>

#include <array>
#include <coroutine>
#include <exception>
#include <memory>
#include <ostream>
#include <type_traits>
#include <utility>

// Dont directly include python headers
Expand Down Expand Up @@ -180,7 +182,7 @@ class PYBIND11_EXPORT PyTaskToCppAwaitable
}
}

bool await_ready() const noexcept
bool await_ready() noexcept // NOLINT(readability-convert-member-functions-to-static)
{
// Always suspend
return false;
Expand Down Expand Up @@ -419,8 +421,8 @@ struct type_caster<mrc::coroutines::Task<ReturnT>>
static handle cast(mrc::coroutines::Task<ReturnT> src, return_value_policy policy, handle parent)
{
// Wrap the object in a CppToPyAwaitable
std::shared_ptr<mrc::pymrc::coro::CppToPyAwaitable> awaitable = std::make_shared<mrc::pymrc::coro::CppToPyAwaitable>(
std::move(src));
std::shared_ptr<mrc::pymrc::coro::CppToPyAwaitable> awaitable =
std::make_shared<mrc::pymrc::coro::CppToPyAwaitable>(std::move(src));

// Convert the object to a python object
auto py_awaitable = pybind11::cast(std::move(awaitable));
Expand Down
4 changes: 2 additions & 2 deletions python/mrc/_pymrc/src/coro.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -23,4 +23,4 @@ namespace py = pybind11;

StopIteration::~StopIteration() = default;

} // namespace mrc::pycoro
} // namespace mrc::pymrc::coro
2 changes: 1 addition & 1 deletion python/mrc/_pymrc/tests/coro/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
Expand Down
7 changes: 4 additions & 3 deletions python/mrc/core/coro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ PYBIND11_MODULE(coro, _module)
.def("__await__", &CppToPyAwaitable::await)
.def("__next__", &CppToPyAwaitable::next);

py::class_<BoostFibersMainPyAwaitable, CppToPyAwaitable, std::shared_ptr<BoostFibersMainPyAwaitable>>(
_module, "BoostFibersMainPyAwaitable")
py::class_<BoostFibersMainPyAwaitable, CppToPyAwaitable, std::shared_ptr<BoostFibersMainPyAwaitable>>( //
_module,
"BoostFibersMainPyAwaitable")
.def(py::init<>());

_module.def("wrap_coroutine", [](coroutines::Task<std::vector<std::string>> fn) -> coroutines::Task<std::string> {
Expand All @@ -64,4 +65,4 @@ PYBIND11_MODULE(coro, _module)
// _module.attr("__version__") =
// MRC_CONCAT_STR(morpheus_VERSION_MAJOR << "." << morpheus_VERSION_MINOR << "." << morpheus_VERSION_PATCH);
}
} // namespace mrc::pycoro
} // namespace mrc::pymrc::coro
3 changes: 2 additions & 1 deletion python/tests/test_pycoro.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
# limitations under the License.

import asyncio

import pytest

from mrc.core import coro as pycoro # pylint: disable=morpheus-incorrect-lib-from-import
from mrc._pymrc.tests.coro.coro import call_async
from mrc._pymrc.tests.coro.coro import call_fib_async
from mrc._pymrc.tests.coro.coro import raise_at_depth_async
from mrc.core import coro as pycoro


@pytest.mark.asyncio
Expand Down

0 comments on commit 5a807f6

Please sign in to comment.