Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: remove configwritermixin class #2921

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ Josh Shields <[email protected]>
Karan Desai <[email protected]>
Karan Desai <[email protected]> karandesai-96 <[email protected]>

Karthik Rishinarada <[email protected]>

Kaushik Varanasi <[email protected]>
Kaushik Varanasi <[email protected]> kaushik94 <[email protected]>

Expand Down
16 changes: 2 additions & 14 deletions tardis/io/configuration/config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import os
import pprint

import pandas as pd
import yaml
from astropy import units as u

from tardis.io.configuration import config_validator
from tardis.io.model.readers.csvy import load_yaml_from_csvy
from tardis.io.util import HDFWriterMixin, YAMLLoader, yaml_load_file
from tardis.io.util import YAMLLoader, yaml_load_file

pp = pprint.PrettyPrinter(indent=4)

Expand Down Expand Up @@ -190,18 +189,7 @@ def deepcopy(self):
return ConfigurationNameSpace(copy.deepcopy(dict(self)))


class ConfigWriterMixin(HDFWriterMixin):
"""
Overrides HDFWriterMixin to obtain HDF properties from configuration keys
"""

def get_properties(self):
data = yaml.dump(self)
data = pd.DataFrame(index=[0], data={"config": data})
return data


class Configuration(ConfigurationNameSpace, ConfigWriterMixin):
class Configuration(ConfigurationNameSpace):
"""
Tardis configuration class
"""
Expand Down
10 changes: 0 additions & 10 deletions tardis/io/configuration/tests/test_config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ def test_from_config_dict(tardis_config_verysimple):
)


def test_config_hdf(hdf_file_path, tardis_config_verysimple):
expected = Configuration.from_config_dict(
tardis_config_verysimple, validate=True, config_dirname="test"
)
expected.to_hdf(hdf_file_path, overwrite=True)
actual = pd.read_hdf(hdf_file_path, key="/simulation/config")
expected = expected.get_properties()["config"]
assert actual[0] == expected[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this test?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
I've tried to pass HDFWriterMixin as parent class to Configuration inorder to utilise get_properties. However when this particular test runs theres an attribute error about hdf_properties and other variables because they are not defined in Configuration class. this was not caught in the original code because we were overwriting get_properties.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, can I get a clarification for this. So that I can make necessary changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do need the capability to write configurations to HDF, so try incorporating HDFWriterMixin into the Configuration class



def test_model_section_config(tardis_config_verysimple):
"""
Configuration Validation Test for Model Section of the Tardis Config YAML File
Expand Down
Loading