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

Minimize conda environment #34626

Closed
tobiasdiez opened this issue Oct 2, 2022 · 3 comments · Fixed by #37447 · May be fixed by #35593
Closed

Minimize conda environment #34626

tobiasdiez opened this issue Oct 2, 2022 · 3 comments · Fixed by #37447 · May be fixed by #35593

Comments

@tobiasdiez
Copy link
Contributor

The dev-conda environment contains quite a lot of packages that are not directly needed to compile or run sage, but only to compile one of sage's dependencies. Since conda already takes care of building the dependency tree (and only including runtime dependencies in it), there is no need to include the deep-dependencies in the environment file. Doing so just unnecessary bloats up the install time and size.

In fact, du -hs /opt/conda/envs/** shows

6.5G    /opt/conda/envs/sage-dev
1.4G    /opt/conda/envs/sage-dev-min

that the sage-dev environment is very large and there is a lot of room for improvement. The second env in the above list corresponds to the following env:

name: sage-dev-min
channels:
  - conda-forge
  - nodefaults
dependencies:
  - tar
  - cypari2 # sagelib/dep
  - singular # sagelib/dep
  - gap-defaults # sagelib/dep
# - html5lib # not referenced in src/
  - libgd # sagelib/dep
  - sagemath-db-polytopes
  - gengetopt
  - symmetrica # sagelib/dep
  - palp
# - sphinxcontrib-websupport # not referenced in src/
  - pkgconfig # sagelib/dep
  - git # Additional dev tool
# - pybind11 # not referenced in src/
  - cliquer # sagelib/dep
  - libatomic_ops
  - pari-elldata
  - zn_poly # sagelib/dep
  - pycodestyle # Additional dev tool
  - pari-galpol
  - gfan # features/gfan
  - memory-allocator # sagelib/dep
  - prompt_toolkit
  - eclib # sagelib/dep
  - arb # sagelib/dep
  - tachyon # sagemath_doc_html/dep
  - bc
  - threejs-sage
  - lcalc # sagelib/dep
  - sagemath-db-graphs
# - ninja # not referenced in src/
  - backports.zoneinfo
# - cppy # not referenced in src/
  - networkx
  - jupyter-jsmol
  - pcre
  - sympy
# - appnope # not referenced in src/
  - flintqs # interfaces/qsieve but not declared as dep
  - r
  - matplotlib
  - r-essentials
  - cvxopt # sagemath-standard/req
  - libhomfly # sagelib/dep
  - pari-seadata
# - poetry-core # not referenced in src/
  - linbox # sagelib/dep
# - importlib_metadata # mentioned in the docs but not used?
  - scipy # sagemath-standard/req
  - patch
# - qhull # not referenced in src/
  - jupyter-packaging
  - jupyter_sphinx # sagemath_doc_html/dependencies
  - compilers
  - esbonio # Additional dev tool
  - openssh # Additional dev tool
  - giac # sagelib/dep
  - fpylll # sagemath-standard/req
  - pplpy # sagelib/dep
# - hatchling # not referenced in src/
  - sagemath-db-elliptic-curves
  - jmol # sagemath_doc_html/dependencies
  - tox # additional dev tool but not declared as such
# - sagetex # not actively referenced in src/
  - primecountpy # sagelib/dep
  - furo # sagemath_doc_html/dependencies
  - rpy2 # sagemath-standard/req
# - pythran # not referenced in src/
  - planarity # sagelib/dep
  - python-lrcalc # sagelib/dep
# - vcversioner # not referenced in src/
  - rw # sagelib/dep
  - brial # sagelib/dep
  - maxima
  - sympow # sage/lfunctions/sympow.py but not declared as dep
  - automake # Package needed for ./bootstrap
  - sagemath-db-combinatorial-designs
# - importlib-resources # not referenced in src/
# - cmake # only mentioned in docs as not often used
# - setuptools_scm # not referenced in src/
  - boost-cpp # sagelib/dep
  - blas # sagelib/dep
  - libbraiding # sagelib/dep
  - mathjax # sagemath_doc_html/dependencies
  - sagemath-db-conway-polynomials

This env has been created using https://github.com/conda-incubator/conda-tree minimizing function (which only takes the leaves of the dependency tree) and then manually going through the remaining dependencies to see which ones are not needed by sage (see comments). Sage compiles within this env, but I've not yet run the doctests. I propose to include this env file directly, replacing the existing automatically generated sage-dev.

Comments about whether the packages without any comments are used/needed are welcome.


To see which packages are still rather big, use

grep '"size":' ${CONDA_PREFIX}/conda-meta/*.json | sort -k3rn | sed 's/.*conda-meta\///g' | column -t

CC: @isuruf @dimpase @saraedum @mkoeppe @slel

Component: build

Author: Tobias Diez

Issue created by migration from https://trac.sagemath.org/ticket/34626

@tobiasdiez tobiasdiez added this to the sage-9.8 milestone Oct 2, 2022
@tobiasdiez

This comment has been minimized.

@mkoeppe
Copy link
Contributor

mkoeppe commented Oct 2, 2022

comment:2

Thanks for investigating this. That's quite a dramatic difference. Could you post a list of the packages in the difference with sizes please?

@mkoeppe mkoeppe modified the milestones: sage-9.8, sage-9.9 Jan 7, 2023
@mkoeppe mkoeppe removed this from the sage-10.0 milestone Apr 30, 2023
tobiasdiez added a commit to tobiasdiez/sage that referenced this issue May 8, 2023
We don't need jupyter-packaging (explicitly, maybe only some dependencies) so conda is able to handle the dependency tree. Part of sagemath#34626. Moreover, its not working with the conda 3.11 test: https://github.com/sagemath/sage/actions/runs/4906896658/jobs/8761652608
@mkoeppe
Copy link
Contributor

mkoeppe commented May 8, 2023

Some of these (as noted in #35627) are only build dependencies (not runtime dependencies) of some Python packages:

(None of these help explain the multi-gigabyte difference.)

It may be useful to mark these packages somehow because also in the Sage distribution, we don't actually need to install them into our venv; it suffices to build wheels for them.

vbraun pushed a commit to vbraun/sage that referenced this issue Dec 11, 2024
…da lock files

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

Using the metadata added in sagemath#37446,
we automatically generate the conda environment files. This no longer
makes any reference to the `conda.txt` files contained in sage-the-
distribution. Thus sage-on-top-of-conda is now completely independent of
sage-the-distribution (only relying on information specified by sage-
the-library). In particular, after this PR is merged the `conda.txt`
files could be deleted from sage-the-distribution.

In particular, we no longer need to maintain the mapping of pypi
packages to conda packages but instead can rely on the offical mappings
maintained by the conda team (https://github.com/regro/cf-graph-
countyfair/tree/master/mappings/pypi).

To test:
```
pip install grayskull conda-lock
python tools/update-conda.py
```

The updated conda files are committed here as well.

Moreover, the `environment-dev` files have been deleted as there was
only little difference between these files and some people rightfully
complained that having too many files in the root folder is distracting.

As a byproduct, this fixes sagemath#34626.

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [ ] The title is concise, informative, and self-explanatory.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

- sagemath#37446: specifies additional
requirements in the pyproject.toml which are used to generate the conda
env files
- sagemath#38983: for the update of numpy
- sagemath#38982: to fix meson build

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#37447
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik, Julian Rüth, Tobias Diez
vbraun pushed a commit to vbraun/sage that referenced this issue Dec 12, 2024
…da lock files

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

Using the metadata added in sagemath#37446,
we automatically generate the conda environment files. This no longer
makes any reference to the `conda.txt` files contained in sage-the-
distribution. Thus sage-on-top-of-conda is now completely independent of
sage-the-distribution (only relying on information specified by sage-
the-library). In particular, after this PR is merged the `conda.txt`
files could be deleted from sage-the-distribution.

In particular, we no longer need to maintain the mapping of pypi
packages to conda packages but instead can rely on the offical mappings
maintained by the conda team (https://github.com/regro/cf-graph-
countyfair/tree/master/mappings/pypi).

To test:
```
pip install grayskull conda-lock
python tools/update-conda.py
```

The updated conda files are committed here as well.

Moreover, the `environment-dev` files have been deleted as there was
only little difference between these files and some people rightfully
complained that having too many files in the root folder is distracting.

As a byproduct, this fixes sagemath#34626.

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [ ] The title is concise, informative, and self-explanatory.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

- sagemath#37446: specifies additional
requirements in the pyproject.toml which are used to generate the conda
env files
- sagemath#38983: for the update of numpy
- sagemath#38982: to fix meson build

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#37447
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik, Julian Rüth, Tobias Diez
@vbraun vbraun closed this as completed in 10ee1bb Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants