Skip to content

Commit 68e0986

Browse files
committed
Get model card in TRITONSERVER_ServerModelMetadata
Signed-off-by: Xiaodong Ye <[email protected]>
1 parent 75dbd17 commit 68e0986

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

src/constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ constexpr char kAutoMixedPrecisionExecutionAccelerator[] =
7171
"auto_mixed_precision";
7272

7373
constexpr char kModelConfigPbTxt[] = "config.pbtxt";
74+
constexpr char kModelCard[] = "README.md";
7475

7576
constexpr char kMetricsLabelModelName[] = "model";
7677
constexpr char kMetricsLabelModelVersion[] = "version";

src/model.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@
3636

3737
namespace triton { namespace core {
3838

39+
Status
40+
Model::GetCard(std::string* contents) const
41+
{
42+
const auto card_path = JoinPath({model_dir_, kModelCard});
43+
RETURN_IF_ERROR(ReadTextFile(card_path, contents));
44+
45+
return Status::Success;
46+
}
47+
3948
Status
4049
Model::GetInput(
4150
const std::string& name, const inference::ModelInput** input) const

src/model.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ class Model {
146146
return stats_aggregator_;
147147
}
148148

149+
// Get the model card for the model being served.
150+
Status GetCard(std::string* contents) const;
151+
149152
// Get the model configuration for a named input.
150153
Status GetInput(
151154
const std::string& name, const inference::ModelInput** input) const;

src/tritonserver.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,6 +2634,13 @@ TRITONSERVER_ServerModelMetadata(
26342634
metadata.AddStringRef("platform", model_config.backend().c_str()));
26352635
}
26362636

2637+
std::string card;
2638+
model->GetCard(&card);
2639+
if (!card.empty()) {
2640+
RETURN_IF_STATUS_ERROR(
2641+
metadata.AddStringRef("card", card.c_str()));
2642+
}
2643+
26372644
triton::common::TritonJson::Value inputs(
26382645
metadata, triton::common::TritonJson::ValueType::ARRAY);
26392646
for (const auto& io : model_config.input()) {

0 commit comments

Comments
 (0)