This commit is contained in:
Anton Schwaighofer 2023-11-07 09:26:29 +00:00 коммит произвёл GitHub
Родитель f3525192e1
Коммит 83df149051
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 30 добавлений и 25 удалений

Просмотреть файл

@ -8,7 +8,7 @@ from io import StringIO
from typing import Any, Dict, Iterable, Union, List, Optional
import param
from ruamel import yaml
from ruamel.yaml import YAML
def is_basic_type(o: Any) -> bool:
@ -138,7 +138,13 @@ def object_to_yaml(o: Any) -> str:
:param o: The object to inspect.
:return: A string in YAML format.
"""
return yaml.safe_dump(object_to_dict(o), default_flow_style=False) # type: ignore
yaml = YAML(typ='safe', pure=True)
stream = StringIO()
yaml.default_flow_style = False
yaml.dump(object_to_dict(o), stream)
result = stream.getvalue()
stream.close()
return result
def yaml_to_dict(s: str) -> Dict[str, Any]:
@ -150,7 +156,8 @@ def yaml_to_dict(s: str) -> Dict[str, Any]:
or dictionaries again.
"""
stream = StringIO(s)
return yaml.safe_load(stream=stream)
yaml = YAML(typ='safe', pure=True)
return yaml.load(stream=stream)
def _write_dict_to_object(o: Any, d: Dict[str, Any], traversed_fields: Optional[List] = None) -> List[str]:

Просмотреть файл

@ -77,7 +77,7 @@ from testazure.utils_testazure import (
)
INEXPENSIVE_TESTING_CLUSTER_NAME = "lite-testing-ds2"
EXPECTED_QUEUED = "This command will be run in AzureML:"
EXPECTED_QUEUED = "Successfully queued run"
GITHUB_SHIBBOLETH = "GITHUB_RUN_ID" # https://docs.github.com/en/actions/reference/environment-variables
AZUREML_FLAG = himl.AZUREML_FLAG

Просмотреть файл

@ -10,7 +10,7 @@ numpy==1.22.0
pillow==9.3.0
pydicom==2.3.0
scikit-image==0.19.3
scipy==1.7.3
scipy==1.10.0
seaborn==0.10.1
simpleitk==2.1.1.2
tifffile==2022.10.10

Просмотреть файл

@ -143,7 +143,7 @@ def test_ssl_container_cifar10_resnet_simclr() -> None:
# Note: It is possible that after the PyTorch 1.10 upgrade, we can't get parity between local runs and runs on
# the hosted build agents. If that suspicion is confirmed, we need to add branching for local and cloud results.
expected_metrics = {
'simclr/val/loss': 2.8596301078796387,
'simclr/val/loss': 2.859630584716797,
'ssl_online_evaluator/val/loss': 2.2664988040924072,
'ssl_online_evaluator/val/AccuracyAtThreshold05': 0.20000000298023224,
'simclr/train/loss': 3.6261773109436035,

Просмотреть файл

@ -2,7 +2,7 @@ bump2version==1.0.1
coverage==6.3.2
flake8==5.0.2
ipykernel==6.15.0
ipython==7.34.0
ipython==8.11.0
mypy==0.931
papermill==2.3.4
pycobertura==2.0.1

Просмотреть файл

@ -13,7 +13,7 @@ from pathlib import Path
from typing import Any, Dict, List, Optional, OrderedDict, Tuple
import jinja2
import ruamel.yaml
from ruamel.yaml import YAML
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
@ -407,7 +407,8 @@ class HTMLReport:
# TODO: add option to overwrite report title with entry here
assert report_config_path.suffix == ".yml", f"Expected a .yml file but found {report_config_path.suffix}"
with open(report_config_path, "r") as f_path:
yaml_contents = ruamel.yaml.load(f_path)
yaml = YAML(typ='safe', pure=True)
yaml_contents = yaml.load(f_path)
return yaml_contents

Просмотреть файл

@ -11,7 +11,7 @@ import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pytest
import ruamel.yaml
from ruamel.yaml import YAML
from ruamel.yaml.comments import CommentedMap as OrderedDict, CommentedSeq as OrderedList
from health_ml.utils.reports import HTMLReport, IMAGE_KEY_HTML, TABLE_KEY_HTML, REPORT_CONTENTS_KEY, ReportComponentKey
@ -226,28 +226,25 @@ def test_html_report_read_config(html_report: HTMLReport, dummy_df: pd.DataFrame
plt.plot(dummy_df[[dummy_df_cols[0]]], dummy_df[[dummy_df_cols[1]]])
report_config_contents = OrderedDict(
{
REPORT_CONTENTS_KEY: OrderedList(
[
{
ReportComponentKey.TYPE.value: ReportComponentKey.TABLE.value,
ReportComponentKey.VALUE.value: table_path,
}
]
)
}
)
report_config_contents = {
REPORT_CONTENTS_KEY: [
{
ReportComponentKey.TYPE.value: ReportComponentKey.TABLE.value,
ReportComponentKey.VALUE.value: str(table_path),
}
]
}
report_config_path = tmp_path / "report_config.yml"
with open(report_config_path, "w+") as f_path:
ruamel.yaml.dump(report_config_contents, f_path)
with open(report_config_path, "w+", encoding="utf-8") as f_path:
yaml = YAML(typ='safe', pure=True)
yaml.dump(report_config_contents, f_path)
report_config = html_report.read_config_yaml(report_config_path)
assert list(report_config.keys()) == [REPORT_CONTENTS_KEY]
assert len(report_config[REPORT_CONTENTS_KEY]) == 1
report_contents_first_entry = report_config[REPORT_CONTENTS_KEY][0]
assert report_contents_first_entry[ReportComponentKey.TYPE.value] == ReportComponentKey.TABLE.value
assert report_contents_first_entry[ReportComponentKey.VALUE.value] == table_path
assert report_contents_first_entry[ReportComponentKey.VALUE.value] == str(table_path)
html_report.add_yaml_contents_to_report(report_config)
html_template_difference = html_report.template.replace(html_template_before, "")