[Streaming] fix streaming ci (#9675)

This commit is contained in:
chaokunyang
2020-09-08 22:20:58 +08:00
committed by GitHub
parent aa79542c77
commit 3645a05644
16 changed files with 177 additions and 75 deletions
+23 -20
View File
@@ -75,7 +75,8 @@ class BaseID {
protected:
BaseID(const std::string &binary) {
RAY_CHECK(binary.size() == Size() || binary.size() == 0)
<< "expected size is " << Size() << ", but got " << binary.size();
<< "expected size is " << Size() << ", but got data " << binary << " of size "
<< binary.size();
std::memcpy(const_cast<uint8_t *>(this->Data()), binary.data(), binary.size());
}
// All IDs are immutable for hash evaluations. MutableData is only allow to use
@@ -341,24 +342,25 @@ std::ostream &operator<<(std::ostream &os, const TaskID &id);
std::ostream &operator<<(std::ostream &os, const ObjectID &id);
std::ostream &operator<<(std::ostream &os, const PlacementGroupID &id);
#define DEFINE_UNIQUE_ID(type) \
class RAY_EXPORT type : public UniqueID { \
public: \
explicit type(const UniqueID &from) { \
std::memcpy(&id_, from.Data(), kUniqueIDSize); \
} \
type() : UniqueID() {} \
static type FromRandom() { return type(UniqueID::FromRandom()); } \
static type FromBinary(const std::string &binary) { return type(binary); } \
static type Nil() { return type(UniqueID::Nil()); } \
static size_t Size() { return kUniqueIDSize; } \
\
private: \
explicit type(const std::string &binary) { \
RAY_CHECK(binary.size() == Size() || binary.size() == 0) \
<< "expected size is " << Size() << ", but got " << binary.size(); \
std::memcpy(&id_, binary.data(), binary.size()); \
} \
#define DEFINE_UNIQUE_ID(type) \
class RAY_EXPORT type : public UniqueID { \
public: \
explicit type(const UniqueID &from) { \
std::memcpy(&id_, from.Data(), kUniqueIDSize); \
} \
type() : UniqueID() {} \
static type FromRandom() { return type(UniqueID::FromRandom()); } \
static type FromBinary(const std::string &binary) { return type(binary); } \
static type Nil() { return type(UniqueID::Nil()); } \
static size_t Size() { return kUniqueIDSize; } \
\
private: \
explicit type(const std::string &binary) { \
RAY_CHECK(binary.size() == Size() || binary.size() == 0) \
<< "expected size is " << Size() << ", but got data " << binary << " of size " \
<< binary.size(); \
std::memcpy(&id_, binary.data(), binary.size()); \
} \
};
#include "ray/common/id_def.h"
@@ -385,7 +387,8 @@ T BaseID<T>::FromRandom() {
template <typename T>
T BaseID<T>::FromBinary(const std::string &binary) {
RAY_CHECK(binary.size() == T::Size() || binary.size() == 0)
<< "expected size is " << T::Size() << ", but got " << binary.size();
<< "expected size is " << T::Size() << ", but got data " << binary << " of size "
<< binary.size();
T t;
std::memcpy(t.MutableData(), binary.data(), binary.size());
return t;
+1 -1
View File
@@ -120,7 +120,7 @@ ObjectID TaskSpecification::ReturnId(size_t return_index) const {
}
bool TaskSpecification::ArgByRef(size_t arg_index) const {
return message_->args(arg_index).object_ref().object_id() != "";
return message_->args(arg_index).has_object_ref();
}
ObjectID TaskSpecification::ArgId(size_t arg_index) const {
+1 -1
View File
@@ -41,7 +41,7 @@ class TaskArgByValue : public TaskArg {
///
/// \param[in] value Value of the argument.
/// \return The task argument.
TaskArgByValue(const std::shared_ptr<RayObject> &value) : value_(value) {
explicit TaskArgByValue(const std::shared_ptr<RayObject> &value) : value_(value) {
RAY_CHECK(value) << "Value can't be null.";
}
@@ -46,7 +46,7 @@ void InlineDependencies(
if (!it->second->IsInPlasmaError()) {
// The object has not been promoted to plasma. Inline the object by
// clearing the reference and replacing it with the raw value.
mutable_arg->mutable_object_ref()->Clear();
mutable_arg->clear_object_ref();
if (it->second->HasData()) {
const auto &data = it->second->GetData();
mutable_arg->set_data(data->Data(), data->Size());
+2
View File
@@ -21,9 +21,11 @@
*ray*TaskID*
*ray*ActorID*
*ray*ObjectID*
*ray*ObjectReference*
# Others
*ray*CoreWorker*
*PyInit*
*init_raylet*
*Java*
*JNI_*
*ray*streaming*
+2
View File
@@ -23,11 +23,13 @@ VERSION_1.0 {
*ray*TaskID*;
*ray*ActorID*;
*ray*ObjectID*;
*ray*ObjectReference*;
# Others
*ray*CoreWorker*;
*PyInit*;
*init_raylet*;
*Java*;
*JNI_*;
*ray*streaming*;
local: *;
};
+34
View File
@@ -0,0 +1,34 @@
#include "ray/streaming/streaming.h"
#include "ray/core_worker/core_worker.h"
namespace ray {
namespace streaming {
void SendInternal(const ActorID &peer_actor_id, std::shared_ptr<LocalMemoryBuffer> buffer,
RayFunction &function, int return_num,
std::vector<ObjectID> &return_ids) {
std::unordered_map<std::string, double> resources;
std::string name = function.GetFunctionDescriptor()->DefaultTaskName();
TaskOptions options{name, return_num, resources};
char meta_data[3] = {'R', 'A', 'W'};
std::shared_ptr<LocalMemoryBuffer> meta =
std::make_shared<LocalMemoryBuffer>((uint8_t *)meta_data, 3, true);
std::vector<std::unique_ptr<TaskArg>> args;
if (function.GetLanguage() == Language::PYTHON) {
auto dummy = "__RAY_DUMMY__";
std::shared_ptr<LocalMemoryBuffer> dummyBuffer =
std::make_shared<LocalMemoryBuffer>((uint8_t *)dummy, 13, true);
args.emplace_back(new TaskArgByValue(std::make_shared<RayObject>(
std::move(dummyBuffer), meta, std::vector<ObjectID>(), true)));
}
args.emplace_back(new TaskArgByValue(std::make_shared<RayObject>(
std::move(buffer), meta, std::vector<ObjectID>(), true)));
std::vector<std::shared_ptr<RayObject>> results;
CoreWorkerProcess::GetCoreWorker().SubmitActorTask(peer_actor_id, function, args,
options, &return_ids);
}
} // namespace streaming
} // namespace ray
+21
View File
@@ -0,0 +1,21 @@
#pragma once
#include "ray/common/buffer.h"
#include "ray/common/id.h"
#include "ray/core_worker/common.h"
// This header is used to warp some streaming code so we can reduce suspicious
// symbols export.
namespace ray {
namespace streaming {
/// Send buffer internal
/// \param[in] buffer buffer to be sent.
/// \param[in] function the function descriptor of peer's function.
/// \param[in] return_num return value number of the call.
/// \param[out] return_ids return ids from SubmitActorTask.
void SendInternal(const ActorID &peer_actor_id, std::shared_ptr<LocalMemoryBuffer> buffer,
RayFunction &function, int return_num,
std::vector<ObjectID> &return_ids);
} // namespace streaming
} // namespace ray