LCOV - code coverage report
Current view: top level - coll_communicator_mgr/rank_graph/rank_table_info - changed_rank_info.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 25 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 3 0

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #include "changed_rank_info.h"
      12              : #include <unordered_set>
      13              : #include <unordered_map>
      14              : #include <sstream>
      15              : #include "json_parser.h"
      16              : #include "exception_util.h"
      17              : #include "log.h"
      18              : 
      19              : namespace Hccl {
      20              : 
      21            0 : std::string ChangedRankInfo::Describe() const
      22              : {
      23              :     return StringFormat(
      24            0 :         "ChangedRankInfo[version=%s, rankCount=%u, ranks size=%d]", version.c_str(), rankCount, ranks.size());
      25              : }
      26              : 
      27            0 : void ChangedRankInfo::Dump() const
      28              : {
      29            0 :     HCCL_DEBUG("ChangedRankInfo Dump:");
      30            0 :     HCCL_DEBUG("%s", Describe().c_str());
      31            0 :     HCCL_DEBUG("ranks:");
      32            0 :     for (const auto& rank : ranks) {
      33            0 :         HCCL_DEBUG("%s", rank.Describe().c_str());
      34            0 :         for (const auto& levelInfo : rank.rankLevelInfos) {
      35            0 :             HCCL_DEBUG("    %s", levelInfo.Describe().c_str());
      36              :         }
      37              :     }
      38            0 : }
      39              : 
      40            0 : void ChangedRankInfo::Deserialize(const nlohmann::json& changedRankInfoJson)
      41              : {
      42            0 :     std::string msgVersion = "[ChangedRankInfo] error occurs when parser object of propName \"version\"";
      43            0 :     std::string msgRankcount = "[ChangedRankInfo] error occurs when parser object of propName \"rank_count\"";
      44            0 :     TRY_CATCH_THROW(InvalidParamsException, msgVersion, version = GetJsonProperty(changedRankInfoJson, "version"););
      45            0 :     TRY_CATCH_THROW(InvalidParamsException, msgRankcount,
      46              :                     rankCount = GetJsonPropertyUInt(changedRankInfoJson, "rank_count"););
      47              : 
      48            0 :     nlohmann::json rankJsons;
      49            0 :     std::string msgRanklist = "error occurs when parser object of propName \"rank_list\"";
      50            0 :     TRY_CATCH_THROW(InvalidParamsException, msgRanklist,
      51              :                     GetJsonPropertyList(changedRankInfoJson, "rank_list", rankJsons););
      52            0 :     for (auto& rankJson : rankJsons) {
      53            0 :         NewRankInfo rankInfo;
      54            0 :         rankInfo.Deserialize(rankJson);
      55            0 :         ranks.emplace_back(rankInfo);
      56            0 :     }
      57            0 : }
      58              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1