FormingWorlds / JANUS

1-D prescribed atmosphere model of planetary atmospheres that makes use of the SOCRATES radiative transfer code.
https://fwl-janus.readthedocs.io
Apache License 2.0
1 stars 0 forks source link

Packaging #18

Closed lsoucasse closed 6 months ago

lsoucasse commented 6 months ago

This work reorganizes the Janus repository so that it becomes a PyPI package.

The main change is that the Socrates radiation code is now put out of the repository for clarity. It is assumed that is is preinstalled before installing and using Janus (see new README.md).

Module sources are now in the src folder, as well as all data files (spectral files and luminosity tracks). Other utility scripts are in the tools folder. Demo scripts are in the test folder for future GH actions to be set up.

timlichtenberg commented 6 months ago

@lsoucasse Just for confirmation: you specifically selected Harrison and Stef to review this, right? Fine for me, just to avoid confusion. :)

lsoucasse commented 6 months ago

@lsoucasse Just for confirmation: you specifically selected Harrison and Stef to review this, right? Fine for me, just to avoid confusion. :)

Yes, because it is software-oriented and not model-oriented. But I am happy to add you as well.

nichollsh commented 6 months ago

I am getting an error when running pip install -e .

(test) [18:54:38] nichollsh@atmlxint6:~/test/my_janus
$ pip install -e .
Obtaining file:///home/n/nichollsh/test/my_janus
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Installing backend dependencies ... done
  Preparing editable metadata (pyproject.toml) ... done
Collecting importlib (from fwl-janus==24.4.4)
  Using cached importlib-1.0.4.zip (7.1 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      ERROR: Can not execute `setup.py` since setuptools is not available in the build environment.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Maybe this originates from using Conda? This is with a fresh Conda environment created with conda create -n test python=3.10

(test) [18:56:25] nichollsh@atmlxint6:~/test/my_janus
$ conda list
# packages in environment at /home/n/nichollsh/nobackups/miniconda3/envs/test:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             5.1                       1_gnu  
bzip2                     1.0.8                h5eee18b_6  
ca-certificates           2024.3.11            h06a4308_0  
ld_impl_linux-64          2.38                 h1181459_1  
libffi                    3.4.4                h6a678d5_1  
libgcc-ng                 11.2.0               h1234567_1  
libgomp                   11.2.0               h1234567_1  
libstdcxx-ng              11.2.0               h1234567_1  
libuuid                   1.41.5               h5eee18b_0  
ncurses                   6.4                  h6a678d5_0  
openssl                   3.0.13               h7f8727e_2  
pip                       24.0            py310h06a4308_0  
python                    3.10.14              h955ad1f_1  
readline                  8.2                  h5eee18b_0  
setuptools                70.0.0                   pypi_0    pypi
sqlite                    3.45.3               h5eee18b_0  
tk                        8.6.14               h39e8969_0  
tzdata                    2024a                h04d1e81_0  
wheel                     0.43.0          py310h06a4308_0  
xz                        5.4.6                h5eee18b_1  
zlib                      1.2.13               h5eee18b_1 
nichollsh commented 6 months ago

It now installs fine. To get it working, I removed importlib from the pyproject.toml file (as suggested here), and also installed a version of setuptools packaged by conda rather than by pip. It was also missing the dependency f90nml.

With these changes, the model output looks good. Do you want me to push these to this branch, @lsoucasse ?

lsoucasse commented 6 months ago

It now installs fine. To get it working, I removed importlib from the pyproject.toml file (as suggested here), and also installed a version of setuptools packaged by conda rather than by pip. It was also missing the dependency f90nml.

With these changes, the model output looks good. Do you want me to push these to this branch, @lsoucasse ?

Yes, please do.

nichollsh commented 6 months ago

I agree. Maybe we could pull the spectral files from OSF using this library?

lsoucasse commented 6 months ago

Hi @lsoucasse , looks good, it seems to install fine with pip install -e . and pip install . on python 3.12. It's a bit difficult to test everything, because there are no tests. I tried to import some files and it seems mostly fine.

Couple of notes:

* pyproject.toml is missing metadata, like the required python version, licence information, urls, etc: https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#a-full-example

* Missing import: f90nml, phys, seaborn

* The package is very large with a 230 MB download, and 873 MB unpacked. Nearly all of this is about the spectral files that are stored as plain text (872 MB). This is something we could think of optimizing.

Thanks @stefsmeets !

nichollsh commented 6 months ago

The code certainly requires Python >= 3.10, because it includes some match statements which were only introduced in that version. I've been using 3.11 recently, but I think 3.10 is a reasonable requirement.

I agree that we should leave at least 1 spectral file in for tests, and that we should think about the rest.

lsoucasse commented 6 months ago

All good, I was thinking of being explicit about the licence like so:

[project]
license = {text = "Apache 2.0 License"}

This will show up nicer in pip show and other places, because it does not copy the entire file 😅

And also keywords which are useful for pypi:

[project]
keywords = ["egg", "bacon", "sausage", "tomatoes", "Lobster Thermidor"]

@timlichtenberg and @nichollsh, do you have any relevant keyword in mind for the Janus package? I would suggest "exoplanet" and "atmosphere".