Skip to content

Commit

Permalink
fix yaml could not determine a constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
SidWeng committed Feb 26, 2020
1 parent 3e0208a commit 55700a8
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion aztk/internal/cluster_data/cluster_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def read_cluster_config(self):
blob_path = self.CLUSTER_DIR + "/" + self.CLUSTER_CONFIG_FILE
try:
result = self.blob_client.get_blob_to_text(self.cluster_id, blob_path)
return yaml.load(result.content, Loader=yaml.FullLoader)
return yaml.load(result.content, Loader=yaml.Loader)
except azure.common.AzureMissingResourceHttpError:
raise error.AztkError("Cluster {} doesn't have cluster configuration in storage".format(self.cluster_id))
except yaml.YAMLError:
Expand Down
2 changes: 1 addition & 1 deletion aztk/node_scripts/install/create_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create_user(batch_client):
return

with open(path, "r", encoding="UTF-8") as file:
user_conf = yaml.load(file.read(), Loader=yaml.FullLoader)
user_conf = yaml.load(file.read(), Loader=yaml.Loader)

try:
password = None if user_conf["ssh-key"] else decrypt_password(user_conf)
Expand Down
4 changes: 2 additions & 2 deletions aztk/node_scripts/scheduling/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def load_application(application_file_path):
Read and parse the application from file
"""
with open(application_file_path, encoding="UTF-8") as f:
application = yaml.load(f, Loader=yaml.FullLoader)
application = yaml.load(f, Loader=yaml.Loader)
return application


Expand Down Expand Up @@ -98,4 +98,4 @@ def upload_error_log(error, application_file_path):
def download_task_definition(task_sas_url):
response = scheduling_target.http_request_wrapper(requests.get, task_sas_url, timeout=10)
yaml_serialized_task = response.content
return yaml.load(yaml_serialized_task, Loader=yaml.FullLoader)
return yaml.load(yaml_serialized_task, Loader=yaml.Loader)
2 changes: 1 addition & 1 deletion aztk/node_scripts/scheduling/job_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def read_downloaded_tasks():
for task_definition in tasks_path:
with open(task_definition, "r", encoding="UTF-8") as stream:
try:
tasks.append(yaml.load(stream, Loader=yaml.FullLoader))
tasks.append(yaml.load(stream, Loader=yaml.Loader))
except yaml.YAMLError as exc:
print(exc)
return tasks
Expand Down
2 changes: 1 addition & 1 deletion aztk/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def read_cluster_config(cluster_id: str, blob_client: blob.BlockBlobService):
blob_path = "config.yaml"
try:
result = blob_client.get_blob_to_text(cluster_id, blob_path)
return yaml.load(result.content, Loader=yaml.FullLoader)
return yaml.load(result.content, Loader=yaml.Loader)
except azure.common.AzureMissingResourceHttpError:
logging.warning("Cluster %s doesn't have cluster configuration in storage", cluster_id)
except yaml.YAMLError:
Expand Down
6 changes: 3 additions & 3 deletions aztk_cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _load_config_file(path: str):

with open(path, "r", encoding="UTF-8") as stream:
try:
return yaml.load(stream, Loader=yaml.FullLoader)
return yaml.load(stream, Loader=yaml.Loader)
except yaml.YAMLError as err:
raise aztk.error.AztkError("Error in {0}:\n {1}".format(path, err))

Expand Down Expand Up @@ -95,7 +95,7 @@ def _read_config_file(self, path: str = aztk.utils.constants.DEFAULT_SSH_CONFIG_

with open(path, "r", encoding="UTF-8") as stream:
try:
config = yaml.load(stream, Loader=yaml.FullLoader)
config = yaml.load(stream, Loader=yaml.Loader)
except yaml.YAMLError as err:
raise aztk.error.AztkError("Error in ssh.yaml: {0}".format(err))

Expand Down Expand Up @@ -245,7 +245,7 @@ def _read_config_file(self, path: str = aztk.utils.constants.DEFAULT_SPARK_JOB_C

with open(path, "r", encoding="UTF-8") as stream:
try:
config = yaml.load(stream, Loader=yaml.FullLoader)
config = yaml.load(stream, Loader=yaml.Loader)
except yaml.YAMLError as err:
raise aztk.error.AztkError("Error in job.yaml: {0}".format(err))

Expand Down
4 changes: 2 additions & 2 deletions tests/core/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def test_serialize_simple_model_to_yaml():

assert output == "!!python/object:tests.core.test_models.UserInfo {age: 29, name: John}\n"

info_parsed = yaml.load(output, Loader=yaml.FullLoader)
info_parsed = yaml.load(output, Loader=yaml.Loader)

assert isinstance(info_parsed, UserInfo)
assert info_parsed.name == "John"
Expand All @@ -318,7 +318,7 @@ def test_serialize_nested_model_to_yaml():

assert output == "!!python/object:tests.core.test_models.User\nenabled: true\ninfo: {age: 29, name: John}\nstate: deleting\n"

user_parsed = yaml.load(output, Loader=yaml.FullLoader)
user_parsed = yaml.load(output, Loader=yaml.Loader)

assert isinstance(user_parsed, User)
assert isinstance(user_parsed.info, UserInfo)
Expand Down

0 comments on commit 55700a8

Please sign in to comment.