def read_yaml_file(yaml_path): """Loads a YAML file. :param yaml_path: the path to the yaml file. :return: YAML file parsed content. """ if is_file(yaml_path): try: file_content = sudo_read(yaml_path) yaml = YAML(typ='safe', pure=True) return yaml.safe_load(file_content) except YAMLError as e: raise YAMLError('Failed to load yaml file {0}, due to {1}' ''.format(yaml_path, str(e))) return None
# /usr/bin python # coding=utf-8 from ruamel.yaml import YAML yaml = YAML() f = open('/Users/aina/PycharmProjects/ROS/case/23.yaml', encoding='utf-8') df = f.read() print(type(df)) res = yaml.safe_load(df) print(res) print(type(res))
) try: client.Bucket(data_bucket_name).download_file(model_def_file_path, 'model.zip') client.Bucket(data_bucket_name).download_file(manifest_file_path, 'manifest.yml') except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == "404": print("The object does not exist.") else: raise ''' Update FfDL manifest with the corresponding object storage credentials ''' f = open('manifest.yml', 'r') manifest = yaml.safe_load(f.read()) f.close() manifest['data_stores'][0]['connection']['auth_url'] = s3_url manifest['data_stores'][0]['connection']['user_name'] = s3_access_key_id manifest['data_stores'][0]['connection']['password'] = s3_secret_access_key manifest['data_stores'][0]['training_data']['container'] = data_bucket_name manifest['data_stores'][0]['training_results'][ 'container'] = result_bucket_name f = open('manifest.yml', 'w') yaml.default_flow_style = False yaml.dump(manifest, f) f.close() ''' Submit Training job to FfDL and monitor its status '''
Any, List, Set, Iterable, ) from functools import lru_cache import os.path import gzip import re import urllib.request # To use ruamel.yaml instead of pyyaml: from ruamel.yaml import YAML # type: ignore yaml = YAML(typ="safe") yaml.safe_load = yaml.load from .model import ( App, LimitingSet, InstanceClass, Workload, PerformanceSet, PerformanceValues, Problem, ) from .solution_model import ( SolutionI, SolutionII, SolvingStats, MallooviaStats,