Skip to content

Commit

Permalink
Get model card in TRITONSERVER_ServerModelMetadata
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaodong Ye <[email protected]>
  • Loading branch information
yeahdongcn committed May 14, 2023
1 parent 75dbd17 commit 68e0986
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ constexpr char kAutoMixedPrecisionExecutionAccelerator[] =
"auto_mixed_precision";

constexpr char kModelConfigPbTxt[] = "config.pbtxt";
constexpr char kModelCard[] = "README.md";

constexpr char kMetricsLabelModelName[] = "model";
constexpr char kMetricsLabelModelVersion[] = "version";
Expand Down
9 changes: 9 additions & 0 deletions src/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@

namespace triton { namespace core {

Status
Model::GetCard(std::string* contents) const
{
const auto card_path = JoinPath({model_dir_, kModelCard});
RETURN_IF_ERROR(ReadTextFile(card_path, contents));

return Status::Success;
}

Status
Model::GetInput(
const std::string& name, const inference::ModelInput** input) const
Expand Down
3 changes: 3 additions & 0 deletions src/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ class Model {
return stats_aggregator_;
}

// Get the model card for the model being served.
Status GetCard(std::string* contents) const;

// Get the model configuration for a named input.
Status GetInput(
const std::string& name, const inference::ModelInput** input) const;
Expand Down
7 changes: 7 additions & 0 deletions src/tritonserver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2634,6 +2634,13 @@ TRITONSERVER_ServerModelMetadata(
metadata.AddStringRef("platform", model_config.backend().c_str()));
}

std::string card;
model->GetCard(&card);
if (!card.empty()) {
RETURN_IF_STATUS_ERROR(
metadata.AddStringRef("card", card.c_str()));
}

triton::common::TritonJson::Value inputs(
metadata, triton::common::TritonJson::ValueType::ARRAY);
for (const auto& io : model_config.input()) {
Expand Down

0 comments on commit 68e0986

Please sign in to comment.