-
Notifications
You must be signed in to change notification settings - Fork 285
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
add conda-lock support to conda easyblock #3397
base: develop
Are you sure you want to change the base?
add conda-lock support to conda easyblock #3397
Conversation
I did a |
get_software_root('anaconda3') or get_software_root('miniconda3')): | ||
conda_cmd = 'conda' | ||
elif get_software_root('miniforge3'): | ||
conda_cmd = 'conda-lock' |
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 is not really correct, miniforge3
provides conda
/mamba
(from what I understand) but conda-lock
is a separate Python package.
|
Hi ocaisa, Thank you for your review! I'm trying to modify this easyblock according to your wonderful suggestions. Regarding "Use conda-lock to generate the lock file (may require platform specific support)", I couldn't find the part where EasyBuild could automatically recognise the system architechture. Could you please indicate where I can find this information or if I need to write my own logic to achieve that? If I'm going to do it myself, I suppose I need to transform them into the way conda-lock could recognize, right? (Or the laziest way is to let users specify the platform) FYI, the conda-lock supported platforms look like this:
Regarding "Use the conda_cmd the user asked for to install the package with the conda-lock created lock file", if I understand correctly, I need to use Thank you for your time and help! All the best, |
I'm no expert here, but reading the documentation for # Install conda-lock (should use conda/mamba as requested by the easyconfig, make sure version >= 1.0)
<conda/mamba> install --channel=conda-forge --name=<expected name> conda-lock
# identify the platform using `get_system_info` and create the necessary mapping (there are some useful options here)
conda-lock render -p <platform> (-c <channel> --no-dev-dependencies)
# NOTE: There is a chance that the above command will fail, so need to verify that it worked
# Now that we have a lock file we can use the requested tool for the installation
<conda/mamba> create -n <expected name> --file conda-<platform>.lock |
@@ -50,6 +51,9 @@ def extra_options(extra_vars=None): | |||
'environment_file': [None, "Conda environment.yml file to use with 'conda env create'", CUSTOM], | |||
'remote_environment': [None, "Remote conda environment to use with 'conda env create'", CUSTOM], | |||
'requirements': [None, "Requirements specification to pass to 'conda install'", CUSTOM], | |||
'use_conda_lock': [False, "Whether to use conda-lock for reproducibility", CUSTOM], | |||
'lock_file': [None, "Path to a pre-generated conda-lock file", CUSTOM], |
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'm not sure how this could work as you would need different lock files for different architectures (of course conda-lock
can easily create these, so I guess they could be added as source files).
I agree it could be useful, and if they existed you wouldn't even need to install conda-lock
, you could just use the lock files directly.
I think it would be better to make this a Boolean named lock_file_provided
: given use_conda_lock
is set to true, True
implies that a platform lock file is provided via a patch (since we can ship patches in our easyconfig repository). That way people can go through some manual effort to get the "right" lock files. A False
value means the lock file needs to be generated. You would need to verify that a lock file for the current platform has been provided.
@@ -50,6 +51,9 @@ def extra_options(extra_vars=None): | |||
'environment_file': [None, "Conda environment.yml file to use with 'conda env create'", CUSTOM], | |||
'remote_environment': [None, "Remote conda environment to use with 'conda env create'", CUSTOM], | |||
'requirements': [None, "Requirements specification to pass to 'conda install'", CUSTOM], | |||
'use_conda_lock': [False, "Whether to use conda-lock for reproducibility", CUSTOM], | |||
'lock_file': [None, "Path to a pre-generated conda-lock file", CUSTOM], | |||
'platform': [None, "Platform specified for conda-lock", CUSTOM], |
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.
Drop this, you need to figure out what platform you are actually on, defining it is the opposite of helpful if it doesn't actually match.
|
||
|
||
# use lock_file to create environment | ||
cmd = "%s %s create --file %s -p %s -y" % (self.cfg['preinstallopts'],conda_cmd, platform_rendered_lock_file, self.installdir) |
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.
line too long (138 > 120 characters)
missing whitespace after ','
platform_rendered_lock_file=lock_file | ||
|
||
|
||
# use lock_file to create environment |
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.
too many blank lines (2)
run_cmd(cmd, log_all=True, simple=True) | ||
else: | ||
|
||
platform_rendered_lock_file=lock_file |
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.
missing whitespace around operator
trailing whitespace
# install conda-lock | ||
cmd = "%s install conda-lock" % conda_cmd | ||
run_cmd(cmd, log_all=True, simple=True) | ||
|
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.
blank line contains whitespace
raise EasyBuildError("The provided lock file does not match this platform") | ||
|
||
|
||
if lock_file_type == "multi": |
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.
too many blank lines (2)
return line.split(":", 1)[1].strip() == platform_name | ||
|
||
|
||
if self.cfg['use_conda_lock']: |
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.
too many blank lines (2)
lock_data = yaml.safe_load(f) | ||
return platform_name in lock_data.get('metadata', []).get('platforms',[]) | ||
else: | ||
# for a single-platform rendered lock file like conda-linux64.lock |
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.
expected an indented block (comment)
# for a multi-platform lock file like conda-lock.yml | ||
with open(lock_file, 'r') as f: | ||
lock_data = yaml.safe_load(f) | ||
return platform_name in lock_data.get('metadata', []).get('platforms',[]) |
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.
missing whitespace after ','
file_type = check_lock_file_type(lock_file) | ||
|
||
if file_type == "multi": | ||
# for a multi-platform lock file like conda-lock.yml |
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.
expected an indented block (comment)
} | ||
|
||
return platforms.get(system, {}).get(machine) | ||
|
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.
blank line contains whitespace
Hi ocaisa, Thanks for your review! This time I added a few things:
Please let me know if there's anything wrong or need to be improved. Really appreciate it. All the best, |
Hello, The tests failed due to module yaml not found. Could you please indicate the right way to use yaml module in the test environment? Thanks! All the best, |
@JinyuHan99 I'm on leave until September, won't be able to get back to this until then |
(created using
eb --new-pr
)