Commit f1d89866 authored by Antoine Berchet's avatar Antoine Berchet
Browse files

Make directories appear nicer in yaml dump

parent 0ba7fc44
......@@ -62,14 +62,14 @@ pages:
stage: deploy
image: pycif/pycif-ci:0.2
script:
# - python setup.py install
# - cd docs
# - make html
# - cd ..
# - mkdir .public
# - cp -r docs/build/html .public/
# - mv .public public
- ls -R examples_artifact
- python setup.py install
- rsync -avz examples_artifact/* examples/
- cd docs
- make html
- cd ..
- mkdir .public
- cp -r docs/build/html .public/
- mv .public public
artifacts:
paths:
- public
......
......@@ -2,7 +2,7 @@
FROM ubuntu:20.10
RUN apt update \
&& apt install -y software-properties-common \
&& apt install -y software-properties-common rsync \
&& apt update \
# Install Python
&& apt install -y python3.9 python3-pip \
......
......@@ -76,7 +76,9 @@ def represent_dictionary_order(self, dict_data):
dict_data.items())
def ordered_dump(stream, yml_dict, ref_directories={}, replace_values={}):
def ordered_dump(stream, yml_dict,
ref_directories={}, replace_values={},
noalias=True):
dump_dict = copy.deepcopy(yml_dict)
# Replacing reference directories by "join" syntax
......@@ -89,14 +91,19 @@ def ordered_dump(stream, yml_dict, ref_directories={}, replace_values={}):
yaml.add_representer(OrderedDict, represent_dictionary_order)
# Replace Alias method of dumper if noalias is True
class NoAliasDumper(yaml.Dumper):
def ignore_aliases(self, data):
return True
# Dump yaml to string and remove quotes for later parsing by yaml
todump = yaml.dump(dump_dict).replace("'", "")
todump = yaml.dump(dump_dict, Dumper=NoAliasDumper).replace("'", "")
stream.write(todump)
def dump_join_syntax(yml_dict, ref_alias, ref_dir):
for key in yml_dict:
if type(yml_dict[key]) == OrderedDict:
if type(yml_dict[key]) in [OrderedDict, dict]:
yml_dict[key] = dump_join_syntax(yml_dict[key], ref_alias, ref_dir)
elif type(yml_dict[key]) == str:
......
......@@ -85,8 +85,8 @@ def dummy_config_fwd(ref_dummy, request):
# Dump configuration into CIF examples
current_dir = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
root_dir = os.path.join(current_dir, "../../../")
pytest_dir = tmpdir_str + "/../"
root_dir = os.path.abspath(os.path.join(current_dir, "../../../"))
pytest_dir = os.path.abspath(tmpdir_str + "/../")
example_dir = \
os.path.abspath(os.path.join(root_dir, "examples_artifact/dummy/"))
Path(example_dir).mkdir(parents=True, exist_ok=True)
......
......@@ -59,8 +59,8 @@ def test_integration_adjtltest(dummy_config_inversion, settings):
"subperiod")
current_dir = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
root_dir = os.path.join(current_dir, "../../")
pytest_dir = tmpdir + "/../"
root_dir = os.path.abspath(os.path.join(current_dir, "../../"))
pytest_dir = os.path.abspath(tmpdir + "/../")
example_dir = \
os.path.abspath(os.path.join(root_dir, "examples_artifact/dummy/"))
Path(example_dir).mkdir(parents=True, exist_ok=True)
......
......@@ -151,8 +151,8 @@ def test_integration_inversion(dummy_config_inversion, settings, pytestconfig):
else settings["minimizer"])
current_dir = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
root_dir = os.path.join(current_dir, "../../")
pytest_dir = tmpdir + "/../"
root_dir = os.path.abspath(os.path.join(current_dir, "../../"))
pytest_dir = os.path.abspath(tmpdir + "/../")
example_dir = \
os.path.abspath(os.path.join(root_dir, "examples_artifact/dummy/"))
Path(example_dir).mkdir(parents=True, exist_ok=True)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment