MCPcopy
hub / github.com/PaddlePaddle/PaddleRec / parse_yaml

Method parse_yaml

tools/utils/static_ps/common.py:84–112  ·  view source on GitHub ↗
(self, config)

Source from the content-addressed store, hash-verified

82 print(self.pretty_print_envs(config))
83
84 def parse_yaml(self, config):
85 vs = [int(i) for i in yaml.__version__.split(".")]
86 if vs[0] < 5:
87 use_full_loader = False
88 elif vs[0] > 5:
89 use_full_loader = True
90 else:
91 if vs[1] >= 1:
92 use_full_loader = True
93 else:
94 use_full_loader = False
95
96 if os.path.isfile(config):
97 if six.PY2:
98 with open(config, 'r') as rb:
99 if use_full_loader:
100 _config = yaml.load(rb.read(), Loader=yaml.FullLoader)
101 else:
102 _config = yaml.load(rb.read())
103 return _config
104 else:
105 with open(config, 'r', encoding="utf-8") as rb:
106 if use_full_loader:
107 _config = yaml.load(rb.read(), Loader=yaml.FullLoader)
108 else:
109 _config = yaml.load(rb.read())
110 return _config
111 else:
112 raise ValueError("config {} can not be supported".format(config))
113
114 def get_all_inters_from_yaml(self, file, filters):
115 _envs = self.parse_yaml(file)

Callers 1

Calls 1

loadMethod · 0.80

Tested by

no test coverage detected