Newinstall.sh: I *really* want to use my own conda/python version

Hi,

First, a bug report:
this page, Install with newinstall.sh and eups distrib — LSST Science Pipelines
I believe incorrectly implies that “-P” takes the path to the python executable to use. This does not seem to be true – newinstall.sh seems to add “bin/conda” to the end of the “-P” argument and expects that to be the conda program. Eg,

RUN ./newinstall.sh -b -t -P /opt/conda/bin/python
 ---> Running in 29508bef3246

LSST Software Stack Builder
=======================================================================

Using conda at /opt/conda/bin/python
./newinstall.sh: line 672: /opt/conda/bin/python/bin/activate: Not a directory

whereas this works:

RUN ./newinstall.sh -b -t -P /opt/conda
 ---> Running in c560bb242f9d

LSST Software Stack Builder
=======================================================================

Using conda at /opt/conda
Collecting package metadata (current_repodata.json): ...working...

Second, my goal is to have the LSST software installed in the same conda environment as some other software, which is using the Intel Python stack (with MKL, Intel custom versions of numpy, etc). (I say “environment”, but I’m just using the “base” conda environment.) When I tell newinstall.sh to use my /opt/conda, however, it is installing its own Python, which is even a different version than the one I gave it (3.8 vs 3.7). Is there a way I can tell it, “No, really, use THIS python.”?

Thanks,
–dustin

The science pipelines code does not work with python 3.7.

I believe there is still one FFTW routine in a meas_ package that we use that breaks with MKL.

Okay, my other package can work with Python 3.8 instead, and it looks like the full Intel stack is available…

But when I try to use that with newinstall.sh, it seems to still want to install its own python, numpy, etc. Presumably that’s either because it’s demanding the conda-forge channel, or because it’s demanding exact versions so that my existing ones don’t work? Is there any way to work around this?

I really only need afwImage, so I’m not particularly worried about a meas package incompatibility.

@ktl will have the details but the newinstall script now requires that it has access to the rubin-env conda-forge package. We keep (some of) the conda-forge versions in that meta package pinned to ensure compatibility with a specific weekly and you will see that newinstall.sh has a specific rubin-env version that it will try to install.

Essentially we are assuming that newinstall will install this conda env and then users will install their packages on top. I’m not sure how easy it is to say to newinstall that the user should be trusted and to use whatever conda env it has been given. This might work when installing a couple of packages but, for example, we are sort of relying on the conda-forge compilers at this point so we are not really testing sconsUtils with other compilers. Also note that we pull eups in from conda-forge now.

You could try manually installing rubin-env=0.6.0 into your favorite conda environment to see what it wants to upgrade. We do allow you to “bring your own environment”, but you then become responsible for stack compatibility. I would recommend that you build from source (do not include -t or remove the binary directory from EUPSPKG_PATH) if you’re going this route.

Ok – so if I do

RUN conda config --add channels conda-forge && \
    conda install rubin-env=0.6.0

that doesn’t want to install its own python & numpy, which is good.

But then, if I run the newinstall.sh script (newinstall.sh -b -T -P /opt/conda), it then wants to install its own python.

(Possibly – I can’t follow the logic – because it’s dropping all my channels, here?:
lsst/newinstall.sh at master · lsst/lsst · GitHub )

So how would I go about using my environment?

Thanks for all the help!
-dustin

LSST_CONDA_ENV_NAME=yourname_here bash newinstall.sh -b -T -P /opt/conda ought to do it.

It’s not possible to use the base environment?

Step 11/68 : ENV LSST_CONDA_ENV_NAME=base
 ---> Running in 895562ab1a87
Removing intermediate container 895562ab1a87
 ---> 1fab3ebf6ea3
Step 12/68 : RUN curl -OL https://raw.githubusercontent.com/lsst/lsst/master/scripts/newinstall.sh &&     chmod 755 newinstall.sh &&     ./newinstall.sh -b -T -P /opt/conda
 ---> Running in 40fbdc82a026
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 26053  100 26053    0     0   150k      0 --:--:-- --:--:-- --:--:--  150k

LSST Software Stack Builder
=======================================================================

Using conda at /opt/conda

CondaValueError: The target prefix is the base prefix. Aborting.

Oops, looks like the logic here needs some fixes. I’ve been working on a different script that will replace newinstall.sh, but I’ll look into patching this in the current script.

1 Like

As a short-term workaround, you should be able to newinstall into the default location but then ignore that environment and use LSST_CONDA_ENV_NAME to override it when doing source loadLSST.bash. I believe this even works with LSST_CONDA_ENV_NAME=base.

Hi K-T,

The following seems to be working for me, using your newinstall.sh branch (the newinstall.sh step finishes almost instantaneously; it doesn’t try to install anything new into the conda environment!):
(this is not the whole Dockerfile; before this, I install apt packages and set up my Intel-python conda environment)

ENV BASH_ENV=/etc/bash.bashrc
RUN echo “source /opt/conda/etc/profile.d/conda.sh && conda activate myenv” > /etc/profile.d/myenv.sh
RUN chmod 755 /etc/profile.d/myenv.sh
RUN conda config --add channels conda-forge &&
conda install rubin-env=0.6.0
RUN conda install eups
ENV LSST_CONDA_ENV_NAME=myenv
ENV LSST_CONDA_CHANNELS=“intel conda-forge”
RUN curl -OL https://raw.githubusercontent.com/lsst/lsst/tickets/DM-31235/scripts/newinstall.sh &&
chmod 755 newinstall.sh &&
bash newinstall.sh -b -T -P /opt/conda
ENV EUPS_SHELL=bash
RUN rm /etc/profile.d/myenv.sh /etc/profile.d/conda.sh
RUN source /root/lsst_stack/loadLSST.bash && eups distrib install -t v22_0_1 sconsUtils
RUN source /root/lsst_stack/loadLSST.bash && eups distrib install -t v22_0_1 astshim
RUN source /root/lsst_stack/loadLSST.bash && eups distrib install -t v22_0_1 afw

Thank you for all your help here! I’ll publish this Dockerfile when it’s ready.

cheers,
–dustin

(Looks like I spoke too soon:

Step 22/76 : RUN source /root/lsst_stack/loadLSST.bash && eups distrib install -t v22_0_1 afw
 ---> Running in 9d17244de1c7
  [  1/12 ]  sconsUtils 22.0.1 (already installed) done.
  [  2/12 ]  astshim 22.0.1+01bcf6a671 (already installed) done.
  [  3/12 ]  base 22.0.1+01bcf6a671 ... done.
  [  4/12 ]  sphgeom 22.0.1+01bcf6a671 ... done.
  [  5/12 ]  pex_exceptions 22.0.1+cc34b8281e ... done.
  [  6/12 ]  utils 22.0.1+1a1dd69893 ... tests/test_pybind11.py                      124     23     22      1    82%
tests/test_utils.py                         167      6      4      2    95%
tests/test_wrappers.py                      338      6     10      3    97%
---------------------------------------------------------------------------
TOTAL                                      1581    193    318     50    86%
Coverage HTML written to dir tests/.tests/pytest-utils.xml-htmlcov
Coverage XML written to file tests/.tests/pytest-utils.xml-cov-utils.xml

=========================== short test summary info ============================
FAILED tests/test_deprecated.py::DeprecatedTestCase::test_deprecate_pybind11
=================== 1 failed, 104 passed, 6 skipped in 4.50s ===================
Global pytest run: failed with 1
Failed test output:
Global pytest output is in /root/lsst_stack/stack/miniconda3-py38_4.9.2-0.6.0/EupsBuildDir/Linux64/utils-22.0.1+1a1dd69893/utils-22.0.1+1a1dd69893/tests/.tests/pytest-utils.xml.failed
The following tests failed:
/root/lsst_stack/stack/miniconda3-py38_4.9.2-0.6.0/EupsBuildDir/Linux64/utils-22.0.1+1a1dd69893/utils-22.0.1+1a1dd69893/tests/.tests/pytest-utils.xml.failed
1 tests failed
scons: *** [checkTestStatus] Error 1
scons: building terminated because of errors.
+ exit -4


***** error: from /root/lsst_stack/stack/miniconda3-py38_4.9.2-0.6.0/EupsBuildDir/Linux64/utils-22.0.1+1a1dd69893/build.log:
eups distrib: Failed to build utils-22.0.1+1a1dd69893.eupspkg: Command:
	source "/opt/conda/envs/myenv/eups/bin/setups.sh"; export EUPS_PATH="/root/lsst_stack/stack/miniconda3-py38_4.9.2-0.6.0"; (/root/lsst_stack/stack/miniconda3-py38_4.9.2-0.6.0/EupsBuildDir/Linux64/utils-22.0.1+1a1dd69893/build.sh) >> /root/lsst_stack/stack/miniconda3-py38_4.9.2-0.6.0/EupsBuildDir/Linux64/utils-22.0.1+1a1dd69893/build.log 2>&1 4>/root/lsst_stack/stack/miniconda3-py38_4.9.2-0.6.0/EupsBuildDir/Linux64/utils-22.0.1+1a1dd69893/build.msg
exited with code 252

Log of failing test case in ‘base’:

=================================== FAILURES ===================================
__________________ DeprecatedTestCase.test_deprecate_pybind11 __________________
[gw15] linux -- Python 3.8.11 /opt/conda/envs/myenv/bin/python3.8

self = <test_deprecated.DeprecatedTestCase testMethod=test_deprecate_pybind11>

    def test_deprecate_pybind11(self):
        def old(x):
            """Docstring"""
            return x + 1
        # Use an unusual category
>       old = lsst.utils.deprecate_pybind11(
            old, reason="For testing.", category=PendingDeprecationWarning)

tests/test_deprecated.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
python/lsst/utils/deprecated.py:72: in deprecate_pybind11
    return deprecated.sphinx.deprecated(
/opt/conda/envs/myenv/lib/python3.8/site-packages/deprecated/classic.py:267: in deprecated
    adapter = adapter_cls(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <deprecated.sphinx.SphinxAdapter object at 0x7f36e1dda160>
directive = 'deprecated', reason = 'For testing.', version = None, action = None
category = <class 'PendingDeprecationWarning'>, line_length = 70

    def __init__(
        self,
        directive,
        reason="",
        version="",
        action=None,
        category=DeprecationWarning,
        line_length=70,
    ):
        """
        Construct a wrapper adapter.

        :type  directive: str
        :param directive:
            Sphinx directive: can be one of "versionadded", "versionchanged" or "deprecated".

        :type  reason: str
        :param reason:
            Reason message which documents the deprecation in your library (can be omitted).

        :type  version: str
        :param version:
            Version of your project which deprecates this feature.
            If you follow the `Semantic Versioning <https://semver.org/>`_,
            the version number has the format "MAJOR.MINOR.PATCH".

        :type  action: str
        :param action:
            A warning filter used to activate or not the deprecation warning.
            Can be one of "error", "ignore", "always", "default", "module", or "once".
            If ``None`` or empty, the the global filtering mechanism is used.
            See: `The Warnings Filter`_ in the Python documentation.

        :type  category: type
        :param category:
            The warning category to use for the deprecation warning.
            By default, the category class is :class:`~DeprecationWarning`,
            you can inherit this class to define your own deprecation warning category.

        :type  line_length: int
        :param line_length:
            Max line length of the directive text. If non nul, a long text is wrapped in several lines.
        """
        if not version:
            # https://github.com/tantale/deprecated/issues/40
>           raise ValueError("'version' argument is required in Sphinx directives")
E           ValueError: 'version' argument is required in Sphinx directives

/opt/conda/envs/myenv/lib/python3.8/site-packages/deprecated/sphinx.py:89: ValueError
- generated xml file: /root/lsst_stack/stack/miniconda3-py38_4.9.2-0.6.0/EupsBuildDir/Linux64/utils-22.0.1+1a1dd69893/utils-22.0.1+1a1dd69893/tests/.tests/pytest-utils.xml -

The test failure is because you are using rubin-env 0.6.0 with Science Pipelines v22_0_1 instead of rubin-env 0.4.3.

In addition, here are some more suggestions:

  • You shouldn’t need to conda install eups after installing rubin-env unless you’re trying to ensure that the latest version is present, as rubin-env has always included eups.
  • If you are executing newinstall.sh with bash, you don’t need to chmod 755 it.
  • I don’t think you need to set EUPS_SHELL. It should already be set to sh, and there’s no difference between that and bash to the code.
  • If you eups distrib install afw, it will install all of its dependencies as well, so you shouldn’t need the other two commands.
  • In general, reducing the number of layers in the container is desirable, so combining RUN commands like echo and chmod may be beneficial.

Okay, so is the “CONDA_ENV” keyword the “secret decoder ring” for which version of rubin-env should work with a version of the pipeline?
https://eups.lsst.codes/stack/src/tags/v22_0_1.list

Yeah, this is showing a lot of my process getting to this point, and making debugging easier. The EUPS_SHELL stuff was from me struggling for a long time to get the shell to automatically source a correct set of startup files (conda or LSST) for the various kinds of shell (login, interactive, non-interactive, sh vs bash); it’s very tricky to get that right and avoid having to source LSST.sh at the beginning of each RUN line.

(Also, since your build process is so time-consuming, I didn’t want to edit my Dockerfile too much!! :stuck_out_tongue:)

Officially it’s the version in the appropriately tagged version of newinstall.sh: lsst/newinstall.sh at 22.0.1 · lsst/lsst · GitHub, but this should match what is in the CONDA_ENV comment in the tag file.

Unfortunately, for these early versions we did not precisely follow semantic versioning rules, so 0.6.0 is not fully substitutable for 0.4.3. We hope to do better in the future.

I’m finding that rubin_env 0.4.3 fails the same test case:

============================= test session starts ==============================
platform linux -- Python 3.8.11, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /root/lsst_stack/stack/miniconda3-py38_4.9.2-0.6.0/EupsBuildDir/Linux64/utils-22.0.1+1a1dd69893/utils-22.0.1+1a1dd69893, configfile: setup.cfg
plugins: xdist-2.3.0, openfiles-0.5.0, forked-1.3.0, doctestplus-0.10.1, subtests-0.5.0, flake8-1.0.7, cov-2.12.1, session2file-0.1.11
gw0 I / gw1 I / gw2 I / gw3 I / gw4 I / gw5 I / gw6 I / gw7 I / gw8 I / gw9 I / gw10 I / gw11 I / gw12 I / gw13 I / gw14 I / gw15 I
gw0 [111] / gw1 [111] / gw2 [111] / gw3 [111] / gw4 [111] / gw5 [111] / gw6 [111] / gw7 [111] / gw8 [111] / gw9 [111] / gw10 [111] / gw11 [111] / gw12 [111] / gw13 [111] / gw14 [111] / gw15 [111]

...........s.................................ss..F.s..s.....s............ [ 64%]
......................................                                   [100%]
=================================== FAILURES ===================================
__________________ DeprecatedTestCase.test_deprecate_pybind11 __________________
[gw15] linux -- Python 3.8.11 /opt/conda/envs/myenv/bin/python3.8

self = <test_deprecated.DeprecatedTestCase testMethod=test_deprecate_pybind11>

    def test_deprecate_pybind11(self):
        def old(x):
            """Docstring"""
            return x + 1
        # Use an unusual category
>       old = lsst.utils.deprecate_pybind11(
            old, reason="For testing.", category=PendingDeprecationWarning)

tests/test_deprecated.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
python/lsst/utils/deprecated.py:72: in deprecate_pybind11
    return deprecated.sphinx.deprecated(
/opt/conda/envs/myenv/lib/python3.8/site-packages/deprecated/classic.py:267: in deprecated
    adapter = adapter_cls(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <deprecated.sphinx.SphinxAdapter object at 0x7f4d8dbdac10>
directive = 'deprecated', reason = 'For testing.', version = None, action = None
category = <class 'PendingDeprecationWarning'>, line_length = 70

    def __init__(
        self,
        directive,
        reason="",
        version="",
        action=None,
        category=DeprecationWarning,
        line_length=70,
    ):
        """
        Construct a wrapper adapter.

        :type  directive: str
        :param directive:
            Sphinx directive: can be one of "versionadded", "versionchanged" or "deprecated".

        :type  reason: str
        :param reason:
            Reason message which documents the deprecation in your library (can be omitted).

        :type  version: str
        :param version:
            Version of your project which deprecates this feature.
            If you follow the `Semantic Versioning <https://semver.org/>`_,
            the version number has the format "MAJOR.MINOR.PATCH".

        :type  action: str
        :param action:
            A warning filter used to activate or not the deprecation warning.
            Can be one of "error", "ignore", "always", "default", "module", or "once".
            If ``None`` or empty, the the global filtering mechanism is used.
            See: `The Warnings Filter`_ in the Python documentation.

        :type  category: type
        :param category:
            The warning category to use for the deprecation warning.
            By default, the category class is :class:`~DeprecationWarning`,
            you can inherit this class to define your own deprecation warning category.

        :type  line_length: int
        :param line_length:
            Max line length of the directive text. If non nul, a long text is wrapped in several lines.
        """
        if not version:
            # https://github.com/tantale/deprecated/issues/40
>           raise ValueError("'version' argument is required in Sphinx directives")
E           ValueError: 'version' argument is required in Sphinx directives

/opt/conda/envs/myenv/lib/python3.8/site-packages/deprecated/sphinx.py:89: ValueError
- generated xml file: /root/lsst_stack/stack/miniconda3-py38_4.9.2-0.6.0/EupsBuildDir/Linux64/utils-22.0.1+1a1dd69893/utils-22.0.1+1a1dd69893/tests/.tests/pytest-utils.xml -

---------- coverage: platform linux, python 3.8.11-final-0 -----------
Name                                      Stmts   Miss Branch BrPart  Cover
---------------------------------------------------------------------------
python/lsst/__init__.py                       3      0      0      0   100%
python/lsst/utils/__init__.py                 9      0      0      0   100%
python/lsst/utils/backtrace/__init__.py       1      0      0      0   100%
python/lsst/utils/deprecated.py              17      5      0      0    71%
python/lsst/utils/doImport.py                30      2      8      0    95%
python/lsst/utils/get_caller_name.py         20      0     10      2    93%
python/lsst/utils/inheritDoc.py               9      8      2      0     9%
python/lsst/utils/tests.py                  295     82    132     13    73%
python/lsst/utils/version.py                  6      0      0      0   100%
python/lsst/utils/wrappers.py               142     16     86     15    86%
tests/import_test/__init__.py                 0      0      0      0   100%
tests/import_test/two/three/fail.py           3      2      0      0    33%
tests/import_test/two/three/runtime.py        1      0      0      0   100%
tests/import_test/two/three/success.py        5      0      0      0   100%
tests/test_backtrace.py                      24      2      4      2    86%
tests/test_cache.py                          68     13     18      3    79%
tests/test_decorators.py                     33      4      6      1    87%
tests/test_deprecated.py                     14      6      2      1    56%
tests/test_doImport.py                       49      1      2      1    96%
tests/test_executables.py                    18      5      2      1    70%
tests/test_getPackageDir.py                  22      2      2      1    88%
tests/test_getTempFilePath.py                90      2      2      1    97%
tests/test_get_caller_name.py                37      2      2      1    92%
tests/test_ordering.py                       17      3      2      1    79%
tests/test_pySharedPtr.py                    39      3      2      1    90%
tests/test_pybind11.py                      124     23     22      1    82%
tests/test_utils.py                         167      6      4      2    95%
tests/test_wrappers.py                      338      6     10      3    97%
---------------------------------------------------------------------------
TOTAL                                      1581    193    318     50    86%
Coverage HTML written to dir tests/.tests/pytest-utils.xml-htmlcov
Coverage XML written to file tests/.tests/pytest-utils.xml-cov-utils.xml

=========================== short test summary info ============================
FAILED tests/test_deprecated.py::DeprecatedTestCase::test_deprecate_pybind11
=================== 1 failed, 104 passed, 6 skipped in 4.35s ===================
Global pytest run: failed with 1
Failed test output:
Global pytest output is in /root/lsst_stack/stack/miniconda3-py38_4.9.2-0.6.0/EupsBuildDir/Linux64/utils-22.0.1+1a1dd69893/utils-22.0.1+1a1dd69893/tests/.tests/pytest-utils.xml.failed
The following tests failed:
/root/lsst_stack/stack/miniconda3-py38_4.9.2-0.6.0/EupsBuildDir/Linux64/utils-22.0.1+1a1dd69893/utils-22.0.1+1a1dd69893/tests/.tests/pytest-utils.xml.failed
1 tests failed
scons: *** [checkTestStatus] Error 1
scons: building terminated because of errors.
# conda list | grep rubin
rubin-env                 0.4.3                ha770c72_0    conda-forge

Ouch. What version of deprecated do you currently have in your environment?

# conda list | grep deprecated
deprecated                1.2.12             pyh44b312d_0    conda-forge

That shouldn’t be possible; rubin-env 0.4.3 specifies deprecated <1.2.12. rubinenv-feedstock/meta.yaml at v0.4.3 · conda-forge/rubinenv-feedstock · GitHub

The rubin-env install didn’t seem to go exactly as planned:

Step 11/77 : RUN conda config --add channels conda-forge &&     conda install rubin-env=0.4.3
 ---> Running in abe476e32ddc
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working...
done