Skip to content

feat: Support conda environment definitions to be passed as function pointers, similar to input, params, and resources#1300

Merged
johanneskoester merged 34 commits intosnakemake:mainfrom
kpj:feature-condaeexpansion
Jul 19, 2022
Merged

feat: Support conda environment definitions to be passed as function pointers, similar to input, params, and resources#1300
johanneskoester merged 34 commits intosnakemake:mainfrom
kpj:feature-condaeexpansion

Conversation

@kpj
Copy link
Copy Markdown
Contributor

@kpj kpj commented Dec 13, 2021

Description

This PR allows to specify conda environments using job parameters.

QC

  • The PR contains a test case for the changes or the changes are already covered by an existing test case.
  • The documentation (docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).

@kpj kpj requested a review from johanneskoester as a code owner December 13, 2021 14:21
@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Copy Markdown
Contributor

@johanneskoester johanneskoester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, interesting idea! See below for a better place to handle this.

@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Copy Markdown
Contributor

@johanneskoester johanneskoester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must say now that I think about it I am a bit unsure about the approach here. It kind of breaks with the way files are formatted in Snakemake. So far, we just had path/to/{somename}.yaml where {somename} was a wildcard name. For stuff that is more complex we had functions. In case of e.g. resources definition these functions can already now take params as an additional argument. I think I would prefer to allow the same mechanism for conda envs instead of introducing something new that solely works like this for conda.

@johanneskoester johanneskoester self-assigned this Apr 5, 2022
@kpj
Copy link
Copy Markdown
Contributor Author

kpj commented Apr 5, 2022

I think I don't completely understand what you mean exactly. Are you suggesting to allow functions for the conda directive?
Then instead of:

rule foo:
    [..]
    params:
        env_path=lambda wildcards, input: "custom_logic"
    conda:
        "{params.env_path}"
    [..]

one could write

rule foo:
    [..]
    conda:
        lambda wildcards, input: "custom_logic"
    [..]

@johanneskoester
Copy link
Copy Markdown
Contributor

Yes, exactly. The upside is that the mechanism would be exactly the same as with input, params and resources.

@kpj
Copy link
Copy Markdown
Contributor Author

kpj commented Apr 6, 2022

I agree, that would be a great solution!
Would this be quick for you to implement or could you give me a pointer which part of the code to adapt in order to support this functionality?

kpj and others added 3 commits June 8, 2022 14:19
Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
0.6% 0.6% Duplication

@johanneskoester johanneskoester merged commit 6f582f1 into snakemake:main Jul 19, 2022
johanneskoester added a commit that referenced this pull request Sep 19, 2024
… (#3093)

<!--Add a description of your PR here-->

### QC
<!-- Make sure that you can tick the boxes below. -->

* [x] The PR contains a test case for the changes or the changes are
already covered by an existing test case.
* [x] The documentation (`docs/`) is updated to reflect the changes or
this is not necessary (e.g. if the change does neither modify the
language nor the behavior or functionalities of Snakemake).


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Introduced a caching mechanism for the conda environment expansion,
improving performance by reducing redundant computations.
- **Bug Fixes**
- Enhanced logic for determining cacheability of the conda environment,
ensuring accurate evaluations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
johanneskoester pushed a commit that referenced this pull request Sep 20, 2024
🤖 I have created a release *beep* *boop*
---


##
[8.20.4](v8.20.3...v8.20.4)
(2024-09-20)


### Bug Fixes

* cache conda envs to fix performance regression introduced in
#1300
([#3093](#3093))
([66600c4](66600c4))
* Flatten conda pip dependencies for report rule info
([#3085](#3085))
([56a1f20](56a1f20))
* improve runtime complexity of post-job checkpoint handling
([#3096](#3096))
([ba30781](ba30781))


### Documentation

* Clarify the lookup function docstring
([#3091](#3091))
([94177d5](94177d5))
* Update lookup signature
([#3090](#3090))
([655d6a1](655d6a1))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants