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

Integration Test class for Stratified W7 setup. #558

Merged
merged 13 commits into from
May 12, 2016

Conversation

kdexd
Copy link

@kdexd kdexd commented May 9, 2016

This PR focuses on addition and proper functioning of an integration test class for Stratified W7 setup. This test is classified as a slow test due to its time taken for a run on single core.

Important components added:

  • Configuration file: tardis/tests/tests_slow/w7/config_w7.yml
  • Abundances profile: tardis/tests/tests_slow/w7/abundances_w7.dat
  • Densities profile: tardis/tests/tests_slow/w7/densities_w7.dat
  • Integration test class: tardis/tests/tests_slow/test_w7.py

Other relevant documentation is added in Integration test itself.

* ws | * j_blues_norm_factor

Also assumed `kurucz_cd23_chianti_H_He.h5` file exists in `tmp` directory.
"""
Copy link
Author

Choose a reason for hiding this comment

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

Docstring for explanation related to work in progress.

@wkerzendorf
Copy link
Member

you need to rebase this commit on the other one.


@pytest.mark.skipif(not pytest.config.getoption("--with-slow"),
reason="slow tests can only be run using --with-slow")
class TestW7(object):
Copy link
Member

Choose a reason for hiding this comment

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

This can likely be subclassed.

karandesai-96 added 6 commits May 10, 2016 07:42
@kdexd kdexd force-pushed the w7-integration-test-class branch from 9d415f0 to 48c3622 Compare May 10, 2016 02:49
@kdexd
Copy link
Author

kdexd commented May 10, 2016

@wkerzendorf @yeganer @unoebauer I am experiencing an IOError everytime now, and this test doesn't work. The problem is that tests_slow directoy and its contents are not included the the directory tree created after the build. This problem was not faced earlier while I implemented it pre-GSoC in #508. Infact, the test was run properly and I have reported it in one of the comments. Is there any recent change in build pattern which I am unaware of ?

I had experimentally let this slow test run on Travis of my fork, whether to make sure that my loca copy itself is not faulty. Here is the build job about that. I am facing the same error locally.

* nubar_estimators | * last_line_interaction_angstrom
* ws | * j_blues_norm_factor

Also assumed `kurucz_cd23_chianti_H_He.h5` file exists in `tmp` directory.
Copy link
Member

Choose a reason for hiding this comment

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

why?

Copy link
Author

Choose a reason for hiding this comment

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

It needs an atomic dataset. Once the test gets running, I will update this. Atomic dataset will be provided by user through command line (before this PR gets merged). It is actually too long to type on command line 😅

Copy link
Member

Choose a reason for hiding this comment

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

you should use the existing infrastructure to pass the atomic datafile

Copy link
Author

Choose a reason for hiding this comment

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

Sure, I will do it same as test_tardis_full.py

@wkerzendorf
Copy link
Member

your errors are related to not including these files in a setup_package.py - have a look throughout TARDIS for this file and it shows you how you need to include your files.

Karan Desai added 2 commits May 10, 2016 16:31
- This makes sure that they are included in the
  directoy structure after the build is executed.
reason="slow tests can only be run using --slow")
@pytest.mark.skipif(not pytest.config.getvalue("baseline-data"),
reason="--baseline-data was not specified")
class TestW7:
Copy link
Member

Choose a reason for hiding this comment

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

inherit from object to get new-style classes.

- Make Testw7 class inherit from 'object' for new
  style classes.

- Replace %s style string formatting with .format()
@wkerzendorf
Copy link
Member

@yeganer I'm signing off on this.


# First we check whether atom data file exists at desired path.
self.atom_data_filename = os.path.expanduser(os.path.expandvars(
pytest.config.getvalue('atomic-dataset')))
Copy link
Contributor

Choose a reason for hiding this comment

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

We may want to add a check that the atomic database is the same as used for the baseline data. Otherwise, this test most likely won't pass. Not sure if we have to include this check in the current PR, but something to keep in mind, though. Thoughts, @wkerzendorf, @karandesai-96, @yeganer?

Copy link
Author

Choose a reason for hiding this comment

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

This didn't even come to my mind ! Using a different atomic database would generate different results. So far there is kurucz_cd23_chianti_H_He.h5 everywhere. If this check is added when need arrives, then the purpose of adding that additional check would be more clear and could be specified in PR description more effectively. Waiting for others' opinions 😄

Copy link
Member

Choose a reason for hiding this comment

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

can you just check the uuid of the atomic data set - that would be good.

@unoebauer
Copy link
Contributor

Apart from my inline comment concerning atomic data integrity, I am very happy with the PR. As soon as we've come to a decision concerning this point, we can merge.

Karan Desai added 2 commits May 11, 2016 18:04
- It is to be made sure that baseline data was
  obtained using the same atomic dataset as
  the current test run. Hence both UUID must
  be equal.
# the same atomic dataset as the one used in current test run.
# TODO: This is a quick workaround, generalize it.

kurucz_data_file_uuid = "5ca3035ca8b311e3bb684437e69d75d7"
Copy link
Contributor

@unoebauer unoebauer May 11, 2016

Choose a reason for hiding this comment

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

Not too happy about this quick workaround. You can directly access the UUID and the MD5 checksum of the atomic data file via model.atom_data.uuid1 and model.atom_data.md5. I suggest you add these to your baseline data and then check them against the one of the test run.

Copy link
Author

Choose a reason for hiding this comment

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

Oh, so after the run, I obtain the radial1d_model and that would enable comparison, right ? But wouldn't it be a bit time expensive ? Waiting for twenty minutes or more and finally seeing that the test failed because atom data files weren't same ? Is it fine ?

Copy link
Author

@kdexd kdexd May 11, 2016

Choose a reason for hiding this comment

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

I suggest you add these to your baseline data and then check them against the one of the test run.

Add them in the sense, like a json or yml file in the directory containing baseline data for slow tests, right ?

atom_data:
    name: kurucz_cd23_chianti_H_He.h5
    uuid1: <uuid1>
    md5: <md5>

I think this would conflict with --atomic-dataset argument. In that case we can give the yml file a priority and NOT skip this test if --atomic-dataset is explicitly not provided. Does it sound like a plan ?
@wkerzendorf @yeganer Your thoughts ?

Copy link
Member

Choose a reason for hiding this comment

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

@unoebauer I suggested this quick workaround. I agree that in the long run we want to have this done properly, but my suggestion is to build parts of the framework and then refine. Would that work for you?

Copy link
Contributor

Choose a reason for hiding this comment

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

@wkerzendorf, @karandesai-96 - sure thing. Sorry for holding up the process. Just wanted to flag this again.

Copy link
Author

Choose a reason for hiding this comment

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

Okay if we not do apply this change, though please do let me know about this idea of putting in a yml file like this. If it is good enough, I would keep it in my mind and apply it immediately when required 😉

Copy link
Contributor

@yeganer yeganer May 11, 2016

Choose a reason for hiding this comment

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

You don't have to wait for the run to be completed to access AtomData.
Afaik Atomdata is already an object inside tardis_config(the parsed, validated one) so doing something like tardis_config.atom_data.uuid should work.

About storing the reference: I think hardcoding it into the tests is fine for now, as there won't be any other database in the near future and this is just a simple implementation detail which can be changed anytime in the future.

Copy link
Author

@kdexd kdexd May 11, 2016

Choose a reason for hiding this comment

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

config_yaml = yaml.load(open(self.config_file))
config_yaml['atom_data'] = self.atom_data_filename

We open the config file and do an overwrite with the new path of atom data filename (the one which we provided from command line). It doesn't seem like an object. Did I miss anything ?

Copy link
Author

Choose a reason for hiding this comment

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

Oh sorry, it was a misunderstanding, @yeganer I did as you suggested and it works fine. :)

@unoebauer
Copy link
Contributor

Happy to merge if nobody objects...

@yeganer yeganer self-assigned this May 11, 2016
@yeganer yeganer added ready and removed ready labels May 11, 2016
config_yaml['model']['structure']['filename'] = self.densities

# The config hence obtained will be having appropriate file paths.
tardis_config = Configuration.from_config_dict(config_yaml)
Copy link
Contributor

@yeganer yeganer May 11, 2016

Choose a reason for hiding this comment

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

That's where the config get's validated and where atom_data becomes an object.

If I'm wrong, you can "load" the atomdata manually and pass the object to the config or the model. IIRC they all accept either a string or an AtomData object.
This might be easier anyway, instead of manipulating the config, load the AtomData directly.

Copy link
Author

Choose a reason for hiding this comment

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

This strategy sounds better. I am trying it.

@wkerzendorf
Copy link
Member

@yeganer if you do not object - I'm merging now.

@yeganer
Copy link
Contributor

yeganer commented May 11, 2016

@wkerzendorf I'm objecting for now.

# the same atomic dataset as the one used in current test run.
with h5py.File(self.atom_data_filename, 'r') as slow_test_atom_data_file:
slow_test_data_file_uuid1 = slow_test_atom_data_file.attrs['uuid1']
assert slow_test_data_file_uuid1 == tardis_config.atom_data.uuid1
Copy link
Contributor

@yeganer yeganer May 11, 2016

Choose a reason for hiding this comment

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

this translates to assert a == a
compare tardis_config with your hardcoded uuid

Copy link
Member

Choose a reason for hiding this comment

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

and - that is sensible. if someone uses a different atomic dataset with the same name it will fail.

@yeganer
Copy link
Contributor

yeganer commented May 12, 2016

Looks good now.

@wkerzendorf wkerzendorf merged commit d8eeb9d into tardis-sn:master May 12, 2016
@kdexd kdexd deleted the w7-integration-test-class branch May 12, 2016 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants