Skip to content

Commit

Permalink
remove pycoro in favor of mrc coro
Browse files Browse the repository at this point in the history
  • Loading branch information
cwharris committed Oct 25, 2023
1 parent 183f106 commit 351eeba
Show file tree
Hide file tree
Showing 15 changed files with 13 additions and 664 deletions.
3 changes: 0 additions & 3 deletions morpheus/_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ include(cmake/libmorpheus.cmake)
# Set the default link targets to avoid repeating this
morpheus_utils_python_package_set_default_link_targets(morpheus)

#----------morpheus._lib.pycoro---------
add_subdirectory(pycoro)

# #----------morpheus._lib.common---------
morpheus_add_pybind11_module(common SOURCE_FILES common/module.cpp)

Expand Down
2 changes: 0 additions & 2 deletions morpheus/_lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
from . import llm
from . import messages
from . import modules
from . import pycoro
from . import stages

__all__ = [
"common",
"llm",
"messages",
"modules",
"pycoro",
"stages",
]
2 changes: 1 addition & 1 deletion morpheus/_lib/llm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ list(APPEND MODULE_SOURCE_FILES module.cpp)
morpheus_add_pybind11_module(llm
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
SOURCE_FILES ${MODULE_SOURCE_FILES}
LINK_TARGETS morpheus morpheus._lib.pycoro
LINK_TARGETS morpheus
CURRENT_DIR_IS_MODULE
)

Expand Down
2 changes: 1 addition & 1 deletion morpheus/_lib/llm/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ from __future__ import annotations
import morpheus._lib.llm
import typing
import morpheus._lib.messages
import morpheus._lib.pycoro
import mrc.core.coro
import mrc.core.segment

__all__ = [
Expand Down
6 changes: 3 additions & 3 deletions morpheus/_lib/llm/include/py_llm_engine_stage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#pragma once
#include "py_llm_node.hpp"
#include "pycoro/pycoro.hpp"

#include "morpheus/export.h"
#include "morpheus/llm/input_map.hpp"
Expand Down Expand Up @@ -54,6 +53,7 @@
#include <pybind11/gil.h>
#include <pybind11/pybind11.h>
#include <pybind11/pytypes.h>
#include <pymrc/coro.hpp>
#include <pymrc/types.hpp>
#include <pymrc/utilities/acquire_gil.hpp>

Expand Down Expand Up @@ -156,13 +156,13 @@ class PythonAsyncioScheduler : public mrc::coroutines::Scheduler
LOG(INFO) << "CoroutineRunnable::run() > Calling run_until_complete() on main_task()";

// Use the BoostFibersMainPyAwaitable to allow fibers to be progressed
loop.attr("run_until_complete")(mrc::pycoro::BoostFibersMainPyAwaitable(std::move(task)));
loop.attr("run_until_complete")(mrc::pymrc::coro::BoostFibersMainPyAwaitable(std::move(task)));

LOG(INFO)
<< "CoroutineRunnable::run() > run_until_complete() returned. Waiting for all enqueued tasks to complete ";

// Now wait until all tasks have been processed
loop.attr("run_until_complete")(mrc::pycoro::BoostFibersMainPyAwaitable(
loop.attr("run_until_complete")(mrc::pymrc::coro::BoostFibersMainPyAwaitable(
this->get_task_container().garbage_collect_and_yield_until_empty()));
}

Expand Down
6 changes: 3 additions & 3 deletions morpheus/_lib/llm/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "./include/py_llm_task_handler.hpp"
#include "py_llm_engine_stage.hpp"
#include "py_llm_lambda_node.hpp"
#include "pycoro/pycoro.hpp" // IWYU pragma: keep

#include "morpheus/llm/input_map.hpp"
#include "morpheus/llm/llm_context.hpp"
Expand All @@ -47,6 +46,7 @@
#include <pybind11/pybind11.h> // for arg, init, class_, module_, str_attr_accessor, PYBIND11_MODULE, pybind11
#include <pybind11/pytypes.h> // for dict, sequence
#include <pybind11/stl.h> // IWYU pragma: keep
#include <pymrc/coro.hpp> // IWYU pragma: keep
#include <pymrc/utils.hpp> // for pymrc::import

#include <memory>
Expand All @@ -73,8 +73,8 @@ PYBIND11_MODULE(llm, _module)
// Load the cudf helpers
CudfHelper::load();

// Import the pycoro module
mrc::pymrc::import(_module, "morpheus._lib.pycoro");
// Import the mrc coro module
mrc::pymrc::import(_module, "mrc.core.coro");

// Import the messages module
mrc::pymrc::import(_module, "morpheus._lib.messages");
Expand Down
5 changes: 3 additions & 2 deletions morpheus/_lib/llm/src/py_llm_lambda_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "py_llm_lambda_node.hpp"

#include "pycoro/pycoro.hpp"
#include "pymrc/coro.hpp"

#include "morpheus/llm/llm_context.hpp"
#include "morpheus/llm/llm_node_base.hpp"
Expand All @@ -29,6 +29,7 @@
#include <pybind11/gil.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pymrc/coro.hpp> // IWYU pragma: keep
#include <pymrc/types.hpp>
#include <pymrc/utils.hpp>

Expand Down Expand Up @@ -116,7 +117,7 @@ Task<std::shared_ptr<LLMContext>> PyLLMLambdaNode::execute(std::shared_ptr<LLMCo
mrc::pymrc::PyHolder o_result;
{
pybind11::gil_scoped_release nogil;
o_result = co_await mrc::pycoro::PyTaskToCppAwaitable(std::move(o_task));
o_result = co_await mrc::pymrc::coro::PyTaskToCppAwaitable(std::move(o_task));
DCHECK_EQ(PyGILState_Check(), 0) << "Should not have the GIL after returning from co_await";
}

Expand Down
3 changes: 1 addition & 2 deletions morpheus/_lib/llm/src/py_llm_node_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

#include "py_llm_node_base.hpp"

#include "pycoro/pycoro.hpp"

#include "morpheus/llm/llm_context.hpp"
#include "morpheus/llm/llm_engine.hpp"
#include "morpheus/llm/llm_node.hpp"
Expand All @@ -27,6 +25,7 @@
#include <mrc/coroutines/task.hpp> // IWYU pragma: keep
#include <pybind11/pybind11.h>
#include <pybind11/stl.h> // IWYU pragma: keep
#include <pymrc/coro.hpp> // IWYU pragma: keep

#include <coroutine>

Expand Down
3 changes: 1 addition & 2 deletions morpheus/_lib/llm/src/py_llm_task_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@

#include "py_llm_task_handler.hpp"

#include "pycoro/pycoro.hpp"

#include "morpheus/llm/llm_context.hpp"

#include <mrc/coroutines/task.hpp> // IWYU pragma: keep
#include <pybind11/pybind11.h>
#include <pybind11/stl.h> // IWYU pragma: keep
#include <pymrc/coro.hpp> // IWYU pragma: keep

#include <coroutine>

Expand Down
39 changes: 0 additions & 39 deletions morpheus/_lib/pycoro/CMakeLists.txt

This file was deleted.

29 changes: 0 additions & 29 deletions morpheus/_lib/pycoro/__init__.pyi

This file was deleted.

Loading

0 comments on commit 351eeba

Please sign in to comment.