Skip to content

Commit

Permalink
fix: torch model publish crash and repository
Browse files Browse the repository at this point in the history
  • Loading branch information
beniz authored and mergify[bot] committed Mar 9, 2022
1 parent 72cc87c commit 6a89b83
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions src/backends/torch/torchmodel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,43 +255,39 @@ namespace dd
rapidjson::Document d_model;
d_model.Parse<rapidjson::kParseNanAndInfFlag>(model_sstr.str().c_str());

// apply changes
bool config_update = false;
//- repository
d_config["model"]["repository"].SetString(target_repo.c_str(),
d_config.GetAllocator());

//- crop_size
try
auto d_input = d_config["parameters"]["input"].GetObject();
auto d_mllib = d_config["parameters"]["mllib"].GetObject();
if (d_mllib.HasMember("crop_size"))
{
int crop_size = d_model["parameters"]["mllib"]["crop_size"].GetInt();
if (crop_size > 0)
try
{
int crop_size
= d_model["parameters"]["mllib"]["crop_size"].GetInt();
if (crop_size > 0)
{
d_config["parameters"]["input"]["width"].SetInt(crop_size);
d_config["parameters"]["input"]["height"].SetInt(crop_size);
}
}
catch (RapidjsonException &e)
{
d_config["parameters"]["input"]["width"].SetInt(crop_size);
d_config["parameters"]["input"]["height"].SetInt(crop_size);
}
config_update = true;
}
catch (RapidjsonException &e)
{
config_update = false;
}
//- db
try
{
auto d_input = d_config["parameters"]["input"].GetObject();
if (d_input.HasMember("db"))
d_input["db"].SetBool(false);
auto d_mllib = d_config["parameters"]["mllib"].GetObject();
if (d_mllib.HasMember("db"))
d_input["db"].SetBool(false);
config_update = true;
}
catch (RapidjsonException &e)
{
config_update |= false;
}

if (!config_update)
{
logger->warn("no update required to config.json");
return;
}

// save updated config.json
Expand Down

0 comments on commit 6a89b83

Please sign in to comment.