-
Notifications
You must be signed in to change notification settings - Fork 4
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
Adapter and Docker #67
Conversation
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 have only slightly tested it but code looks fine :)
I'm struggling with the Makefile. Please have a look and see my comments.
Makefile
Outdated
CONDA_ENV := $(APP_NAME) | ||
# Conda | ||
CHECK ?= shell command -v | ||
CONDA_HOME ?= $($(CHECK) conda info --base 2> /dev/null) |
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.
setting CONDA_HOME
didn't work: use previous cmd $(shell conda info --base 2> /dev/null)
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 doesn't work for me.
tmp:
@echo "THE RESULT: $(shell conda info --base 2> /dev/null)"
make tmp
>> THE RESULT:
which conda
>> conda () {
<...>
}
** this is the miniconda output on ubuntu
With only conda info --base 2> /dev/null
(without shell), I get the actual conda home path.
CONDA_ENV ?= $(APP_NAME) | ||
CONDA_BIN := $(CONDA_HOME)/bin/conda | ||
CONDA_TARGET_PREFIX := readlink -e "$(CONDA_HOME)/envs/$(CONDA_ENV)" 2> /dev/null | ||
CONDA_ACTUAL_PREFIX := readlink -e "${CONDA_PREFIX}" 2> /dev/null |
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.
CONDA_PREFIX
is not always defined. On my mac I'm using anaconda system installation and I have to run conda activate
to make conda available.
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.
The idea here is that, CONDA_PREFIX
is indeed not defined, therefore the conda environment is not activated, so the script activates it with CONDA_CMD
before doing any other operation (pip install, etc.).
If the "right" CONDA_ENV == twitcher
conda environment is already activated because the user already did conda activate twitcher
, CONDA_PREFIX
points to it and there is no need for CONDA_CMD
to be executed.
CONDA_ACTUAL_PREFIX := readlink -e "${CONDA_PREFIX}" 2> /dev/null | ||
# don't activate and update conda env if it already is activated | ||
# (avoids long conda 'solving environment' time) | ||
ifeq ($(shell $(CONDA_TARGET_PREFIX)),$(shell $(CONDA_ACTUAL_PREFIX))) |
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 check is "true" when there is both no conda env and no CONDA_PREFIX
... not what we want.
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.
On my side, this works as intended.
On the other hand, the previously used commands were failing on my side :
CONDA := $(shell command -v conda 2> /dev/null)
ANACONDA_HOME := $(shell conda info --base 2> /dev/null)
What values are you getting (use make debug
) ?
I would like to investigate to find a method that works for everyone.
I believe that conda
variants can be very intricate depending on which one it is (anaconda, miniconda, etc.)
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.
On ubuntu docker image I get:
$ make debug
Following variables are used:
SHELL: /bin/sh
CHECK: shell command -v
APP_ROOT: /opt/twitcher
APP_NAME: twitcher
BUMP_XARGS: --verbose --allow-dirty
CONDA_HOME:
CONDA_BIN: /bin/conda
CONDA_ENV: twitcher
CONDA_MSG: Conda environment already activated
CONDA_CMD: echo Conda environment already activated;
CONDA_TARGET_PREFIX [literal]: readlink -e /envs/twitcher 2> /dev/null
CONDA_ACTUAL_PREFIX [called]:
CONDA_TARGET_PREFIX [literal]: readlink -e 2> /dev/null
CONDA_ACTUAL_PREFIX [called]:
DOCKER_TAG: birdhouse/twitcher:0.4.0
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.
miniconda is installed:
which conda
/opt/anaconda/bin/conda
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.
If you run make CHECK="command -v" debug
, does your CONDA_HOME
display a valid path instead of blank?
I suspect that the $(shell $(...))
syntax might be causing the issue.
If that's the case, ifeq (`$(CONDA_TARGET_PREFIX)`,`$(CONDA_ACTUAL_PREFIX)`)
instead of the highlighted code will probably do the trick.
I get the same output for both on my side.
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 run this on my ubuntu docker container ... but does not change it:
$ make CHECK="command -v" debug
Following variables are used:
SHELL: /bin/sh
CHECK: command -v
APP_ROOT: /opt/twitcher
APP_NAME: twitcher
BUMP_XARGS: --verbose --allow-dirty
CONDA_HOME:
CONDA_BIN: /bin/conda
CONDA_ENV: twitcher
CONDA_MSG: Conda environment already activated
CONDA_CMD: echo Conda environment already activated;
CONDA_TARGET_PREFIX [literal]: readlink -e /envs/twitcher 2> /dev/null
CONDA_ACTUAL_PREFIX [called]:
CONDA_TARGET_PREFIX [literal]: readlink -e 2> /dev/null
CONDA_ACTUAL_PREFIX [called]:
DOCKER_TAG: birdhouse/twitcher:0.4.0
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.
Both on ubuntu and on macos I'm using bash. Do you have a different shell which would cause a difference?
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 think it is because of miniconda alternative configs that define conda.csh
scripts to do some pre-processing steps before activating the environment. This causes the conda "bin" to actually point to another script which messes up commands like which
.
If have found that CONDA_EXE
points to the real conda bin path though.
So if it does on your side too in both situations when env is (de)activated, I could adapt the script to use this variable.
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 have CONDA_EXE
only when I run conda activate
:
$ conda activate
$ env | grep -i conda
$ CONDA_EXE=/usr/local/anaconda3/bin/conda
But the env is not defined when I just put the conda-bin in PATH
.
Does which
help?
https://github.com/bird-house/pyramid-phoenix/blob/5c5a4f73778c31abdee13ce004dd651b43f24247/docs/Makefile#L11
Why is the adapter necessary? Do you already have a different adapter implementation? There is an |
@cehbrecht |
@cehbrecht Required for Ouranosinc/Magpie#182 to pull 'base' image of MagpieAdapter+Twitcher. |
Yes, we can use this docker tag: |
@cehbrecht |
make debug looks good:
But still there is an issue ... The manual installation still works:
I would merge this PR and open a new issue for the Makefile. Makefile is "only" needed for user-friendly installation. |
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.
Code looks good. Makefile issue will be solved in a new PR.
@fmigneault merged. Thanks :) |
This PR adds:
AdapterInterface
class that allows overriding 'store' implementations.DefaultAdapter
is used whentwitcher.adapter = default
or is missing, which calls the store creation with the original methodology.