-
-
Notifications
You must be signed in to change notification settings - Fork 426
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
Integration Test class for Stratified W7 setup. #558
Conversation
* ws | * j_blues_norm_factor | ||
|
||
Also assumed `kurucz_cd23_chianti_H_He.h5` file exists in `tmp` directory. | ||
""" |
There was a problem hiding this comment.
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.
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): |
There was a problem hiding this comment.
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.
- --baseline-data argument will acept the path of directory containing the baseline data for assertion. - Fix --with-slow flag, and replace it with --slow, after a rebase on the base branch.
9d415f0
to
48c3622
Compare
@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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
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 😅
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
your errors are related to not including these files in a |
- 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: |
There was a problem hiding this comment.
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()
1d5fa2e
to
d665b9e
Compare
@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'))) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
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.
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. |
- 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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 😉
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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. :)
Happy to merge if nobody objects... |
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@yeganer if you do not object - I'm merging now. |
@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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Looks good now. |
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:
tardis/tests/tests_slow/w7/config_w7.yml
tardis/tests/tests_slow/w7/abundances_w7.dat
tardis/tests/tests_slow/w7/densities_w7.dat
tardis/tests/tests_slow/test_w7.py
Other relevant documentation is added in Integration test itself.