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

fixing mflike test and fixing np.float error #104

Merged
merged 17 commits into from
May 4, 2023
Merged

Conversation

sgiardie
Copy link
Collaborator

Fixing mflike test to remove the dependence from simonsobs/mflike
Also substituting np.float with float, because of python complaining about that

@codecov-commenter
Copy link

codecov-commenter commented Feb 28, 2023

Codecov Report

Merging #104 (2dfc052) into master (7455cf4) will increase coverage by 12.79%.
The diff coverage is 100.00%.

❗ Current head 2dfc052 differs from pull request most recent head c3a013f. Consider uploading reports for the commit c3a013f to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #104       +/-   ##
===========================================
+ Coverage   60.33%   73.12%   +12.79%     
===========================================
  Files          30       30               
  Lines        1931     1935        +4     
===========================================
+ Hits         1165     1415      +250     
+ Misses        766      520      -246     
Impacted Files Coverage Δ
soliket/bandpass.py 44.89% <ø> (+17.34%) ⬆️
soliket/mflike/__init__.py 100.00% <100.00%> (ø)
soliket/mflike/mflike.py 80.88% <100.00%> (+69.88%) ⬆️

... and 2 files with indirect coverage changes

soliket/clusters/survey.py Outdated Show resolved Hide resolved
soliket/tests/test_mflike.py Show resolved Hide resolved
soliket/tests/test_mflike.py Outdated Show resolved Hide resolved
@itrharrison itrharrison added mflike Related to mflike likelihood tests Improvements to tests labels Feb 28, 2023
@itrharrison itrharrison added this to the v0.1 milestone Feb 28, 2023
@sgiardie
Copy link
Collaborator Author

sgiardie commented Mar 1, 2023

I am having an issue with overwriting the default installation url of soliket.mflike.MFLike. I have tried to do that:
install({"likelihood": {"soliket.mflike.MFLike": {"install_options": {"download_url": f"{_url}/{filename}.tar.gz"}}}},path=packages_path, skip_global=False, force=True, debug=True)
where _url is a url different from the default mflike one.
Somehow, this is not enough for cobaya to overwrite the default option. This is the error message I get:

(Pdb) install({"likelihood": {"soliket.mflike.MFLike": {"install_options": {"download_url": f"{_url}/{filename}.tar.gz"}}}},path=packages_path, skip_global=False, force=True, debug=True)
 2023-03-01 11:30:14,387 [install] Installing external packages at '/tmp/LAT_packages'
 2023-03-01 11:30:14,389 [install] The installation path has been written into the global config file: /home/serenagiardiello/.config/cobaya/config.yaml

================================================================================
likelihood:soliket.mflike.MFLike
================================================================================

 2023-03-01 11:30:14,389 [install] 'soliket.mflike.MFLike' could not be found as internal component.
 2023-03-01 11:30:14,389 [install] Checking if dependencies have already been installed...
 2023-03-01 11:30:14,390 [install] External dependencies for this component already installed.
 2023-03-01 11:30:14,390 [install] Forcing re-installation, as requested.
 2023-03-01 11:30:14,390 [install] Installing...
 2023-03-01 11:30:14,390 [soliket.mflike] Downloading likelihood data file: https://portal.nersc.gov/cfs/sobs/users/MFLike_data/v0.6.tar.gz...
 2023-03-01 11:30:14,391 [urllib3.connectionpool] Starting new HTTPS connection (1): portal.nersc.gov:443
 2023-03-01 11:30:15,075 [urllib3.connectionpool] https://portal.nersc.gov:443 "GET /cfs/sobs/users/MFLike_data/v0.6.tar.gz HTTP/1.1" 200 333292955
100%|████████████████████████████████████████████████████████████| 318M/318M [00:30<00:00, 10.8MiB/s]
 2023-03-01 11:30:45,919 [soliket.mflike] Downloaded filename v0.6.tar.gz
 2023-03-01 11:30:45,919 [soliket.mflike] Got: v0.6.tar.gz
 2023-03-01 11:30:48,192 [soliket.mflike] Decompressed: v0.6.tar.gz
 2023-03-01 11:30:48,222 [soliket.mflike] Likelihood data downloaded and uncompressed correctly.
 2023-03-01 11:30:48,222 [install] Successfully installed! Let's check it...
 2023-03-01 11:30:48,222 [install] 'soliket.mflike.MFLike' could not be found as internal component.
 2023-03-01 11:30:48,222 [install] Installation check successful.

================================================================================
* Summary * 
================================================================================

 2023-03-01 11:30:48,222 [install] All requested components' dependencies correctly installed at /tmp/LAT_packages

It does not recognize soliket.mflike.MFLike as an internal component, even though I have imported soliket.mflike.MFLike at the beginning. Then it installs data, but from the default mflike url (the one at nersc).

Sorry @cmbant, do you have an idea why this is not working?

@cmbant
Copy link
Collaborator

cmbant commented Mar 1, 2023

The inheriting/overriding of attributes currently only works at the component instance level, but the install system works on uninstantiated classes, so your input dictionary is not used. It's more intended that you make a new class inheriting from the old one, set new install attributes as needed, and then install the new class.

To allow passing install_options, would have to modify install(), is_installed() and install.py to pass around input parameters. (possibly tricky to maintain consistent version tracking though).

@cmbant
Copy link
Collaborator

cmbant commented Mar 1, 2023

"could not be found as internal component" means that it is not an internal component, but presumably found OK as an external component since the install check passes (i.e. can ignore that line). I would agree some of these install output lines are not super helpful...

@sgiardie
Copy link
Collaborator Author

sgiardie commented Mar 2, 2023

Thanks @cmbant. I followed your advice and created a new class TestMFLike inheriting soliket.MFLike, in order to override its installation default. This was done to download a light mock data file for MFLike (much lighter than the default data), to be used in the test_mflike.py test. To use this TestMFLike class in the test, we had to define it in soliket/mflike.py and to include it as a likelihood of the SOLikeT package by adding it to the soliket/__init__.py.

Is there a better way to override the installation path for soliket.mflike?

@cmbant
Copy link
Collaborator

cmbant commented Mar 2, 2023

I don't think you should have to put it in init (ref to soliket.mflike.TestMFLike I think should load it anyway).

If you just want to be able to dynamically change the path, I guess you could implement get_install_options() in the base likelihood, with the option to change the path via an environment or global variable.

Raise a cobaya issue with a feature request if you think overriding install-time options from inputs would be useful.

Copy link
Collaborator

@itrharrison itrharrison left a comment

Choose a reason for hiding this comment

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

It seems like fully remove mflike as a dependency causes a problem related to syslibrary in theoryforge. @sgiardie @mgerbino is this syslibrary something that is available elsewhere or can have its functionality replicated? Or do we need to keep the mflike dependency?

@sgiardie
Copy link
Collaborator Author

sgiardie commented Mar 8, 2023

It seems like fully remove mflike as a dependency causes a problem related to syslibrary in theoryforge. @sgiardie @mgerbino is this syslibrary something that is available elsewhere or can have its functionality replicated? Or do we need to keep the mflike dependency?

Ok, we are getting syslibrary through mflike, when we can instead just include syslibrary as a separate dipendency... which means having also syslibrary pip installable

itrharrison added a commit that referenced this pull request Mar 8, 2023
* renamed TestLike to CheckLike in test_ccl.py

* replaced distutils.version.Looseversion with packaging.version.Version

* replaced deprecated interp2d with RegularGridInterpolator in clusters

* flake8 compliant

* removed python3.7 from env list in tox.ini

* removed py3.7 from conda reqs

* upgraded latest version to py3.8

* correct data types in shearkappa test file

* edits to setup.cfg for pyversion bump and fgspectra from pip

* mflike actually still required before #104 merged

---------

Co-authored-by: Martina Gerbino <bradamante@martina.local>
Co-authored-by: Ian Harrison <itrharrison@gmail.com>
Copy link
Collaborator Author

@sgiardie sgiardie left a comment

Choose a reason for hiding this comment

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

fixing the test and the np.float error (even though I reversed the correction in the clusters/survey.py module)

Copy link
Collaborator Author

@sgiardie sgiardie left a comment

Choose a reason for hiding this comment

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

fgspectra now pip installable and TestMFLike class created not to download mflike data

@sgiardie sgiardie requested a review from itrharrison May 4, 2023 08:58
@itrharrison itrharrison merged commit e390ed1 into master May 4, 2023
@itrharrison itrharrison deleted the fix_mflike_test branch May 4, 2023 09:22
mgerbino added a commit that referenced this pull request Oct 4, 2023
* renamed TestLike to CheckLike in test_ccl.py

* replaced distutils.version.Looseversion with packaging.version.Version

* replaced deprecated interp2d with RegularGridInterpolator in clusters

* flake8 compliant

* removed python3.7 from env list in tox.ini

* removed py3.7 from conda reqs

* upgraded latest version to py3.8

* correct data types in shearkappa test file

* edits to setup.cfg for pyversion bump and fgspectra from pip

* mflike actually still required before #104 merged

---------

Co-authored-by: Martina Gerbino <bradamante@martina.local>
Co-authored-by: Ian Harrison <itrharrison@gmail.com>
mgerbino pushed a commit that referenced this pull request Oct 4, 2023
* fixing mflike test and fixing np.float error

* fix code style

* temporary changes before I mess up this file again

* it somehow works if I download the datafile by myself

* test installable likelihood in mflike.py

* installable file lighter and change in chi2 values

* removed TestMFLike from __init__

* remove mflike dep

* added gspectra version and syslib deps

* removed planck data install from removed test

* put planck install back (associated with cosmopower test)

---------

Co-authored-by: Ian Harrison <itrharrison@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mflike Related to mflike likelihood tests Improvements to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants