Skip to content

Commit

Permalink
fix(api): re-add parameters in info call
Browse files Browse the repository at this point in the history
  • Loading branch information
Bycob authored and mergify[bot] committed Mar 3, 2023
1 parent b562fee commit df318cb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/dto/info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "common.hpp"
#include "ddtypes.hpp"
#include "parameters.hpp"

namespace dd
{
Expand Down Expand Up @@ -96,6 +97,7 @@ namespace dd
DTO_FIELD(String, description);
DTO_FIELD(String, mllib);
DTO_FIELD(String, mltype);
DTO_FIELD(Object<Parameters>, parameters);

DTO_FIELD_INFO(type)
{
Expand Down
4 changes: 3 additions & 1 deletion src/mlservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,12 @@ namespace dd
serv_dto->type = "unsupervised";
else
serv_dto->type = "supervised";
serv_dto->repository = this->_inputc._model_repo;
serv_dto->parameters
= _init_parameters.createSharedDTO<DTO::Parameters>();

if (this->_has_predict)
{
serv_dto->repository = this->_inputc._model_repo;
serv_dto->width = this->_inputc.width();
serv_dto->height = this->_inputc.height();
}
Expand Down
9 changes: 9 additions & 0 deletions src/utils/oatpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ namespace dd
jval = JVal(rapidjson::kObjectType);
dto_ad->toJVal(jdoc, jval);
}
else if (polymorph.getValueType() == DTO::GpuIds::Class::getType())
{
auto dto_gpuid = polymorph.cast<DTO::GpuIds>();
jval = JVal(rapidjson::kArrayType);
for (size_t i = 0; i < dto_gpuid->_ids.size(); ++i)
{
jval.PushBack(dto_gpuid->_ids[i], jdoc.GetAllocator());
}
}
else if (polymorph.getValueType()->classId.id
== oatpp::data::mapping::type::__class::AbstractVector::
CLASS_ID.id
Expand Down
6 changes: 6 additions & 0 deletions tests/ut-oatpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ void test_services(std::shared_ptr<DedeApiTestClient> client)
ASSERT_TRUE(d["body"].HasMember("jobs"));
ASSERT_TRUE(d["body"].HasMember("model_stats"));
ASSERT_TRUE(d["body"]["model_stats"]["params"].GetInt() == 11177538);
ASSERT_TRUE(d["body"].HasMember("parameters"));
ASSERT_TRUE(d["body"]["parameters"].HasMember("input"));
ASSERT_TRUE(d["body"]["parameters"].HasMember("mllib"));
ASSERT_TRUE(d["body"]["parameters"].HasMember("output"));
ASSERT_EQ(d["body"]["parameters"]["input"]["connector"].GetString(),
std::string("image"));

// info call
response = client->get_info();
Expand Down

0 comments on commit df318cb

Please sign in to comment.