diff --git a/src/constants.h b/src/constants.h index f6b5d8a7c..91a5f3e81 100644 --- a/src/constants.h +++ b/src/constants.h @@ -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"; diff --git a/src/model.cc b/src/model.cc index c59a3170c..3c384612a 100644 --- a/src/model.cc +++ b/src/model.cc @@ -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 diff --git a/src/model.h b/src/model.h index ea1130041..0dcedea1d 100644 --- a/src/model.h +++ b/src/model.h @@ -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; diff --git a/src/tritonserver.cc b/src/tritonserver.cc index 44d8b0988..00af900f9 100644 --- a/src/tritonserver.cc +++ b/src/tritonserver.cc @@ -2634,6 +2634,13 @@ TRITONSERVER_ServerModelMetadata( metadata.AddStringRef("platform", model_config.backend().c_str())); } + std::string card; + RETURN_IF_STATUS_ERROR(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()) {