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

feat: update to snakemake 8 #71

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open

feat: update to snakemake 8 #71

wants to merge 9 commits into from

Conversation

Smeds
Copy link
Contributor

@Smeds Smeds commented Mar 4, 2024

This PR:

(If this is a release PR, no need to add following. Leave this part empty)
(Use the following lines to create a PR text body. Make sure to remove all non-relevant one after you're done)
(Repeat each field as many times as necessary)

Added: for new features.
Changed: for changes in existing functionality.
Deprecated: for soon-to-be removed features.
Removed: for now removed features.
Fixed: for any bug fixes.
Security: in case of vulnerabilities.

Review and tests:

  • Tests pass
  • If you've fixed a bug or added code that should be tested, add tests!
  • Code review
  • CHANGELOG.md is updated
  • New code is executed and covered by tests, and test approve

jonca79
jonca79 previously approved these changes Mar 4, 2024
@maehler
Copy link
Collaborator

maehler commented Mar 5, 2024

Something seems to go wrong with the copy rules when running the integration test. I get the following traceback:

Traceback (most recent call last):
  File "/adhome/nima18/.pyenv/versions/hydra-reports-dev/lib/python3.11/site-packages/snakemake/executors/local.py", line 259, in _callback
    raise ex
  File "/adhome/nima18/.pyenv/versions/3.11.6/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/adhome/nima18/.pyenv/versions/hydra-reports-dev/lib/python3.11/site-packages/snakemake/executors/local.py", line 245, in cached_or_run
    run_func(*args)
  File "/adhome/nima18/.pyenv/versions/hydra-reports-dev/lib/python3.11/site-packages/snakemake/executors/local.py", line 463, in run_wrapper
    raise ex
  File "/adhome/nima18/.pyenv/versions/hydra-reports-dev/lib/python3.11/site-packages/snakemake/executors/local.py", line 420, in run_wrapper
    run(
  File "copy_result_files", line 11, in __rule__copy_cnv_html_report
    import sys
  File "/adhome/nima18/.pyenv/versions/hydra-reports-dev/lib/python3.11/site-packages/snakemake/shell.py", line 281, in __new__
    with benchmarked(proc.pid, bench_record):
  File "/adhome/nima18/.pyenv/versions/3.11.6/lib/python3.11/contextlib.py", line 144, in __exit__
    next(self.gen)
  File "/adhome/nima18/.pyenv/versions/hydra-reports-dev/lib/python3.11/site-packages/snakemake/benchmark.py", line 376, in benchmarked
    result.running_time = time.time() - start_time
    ^^^^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'running_time'

My guess is that something about the rule function signature has changed in snakemake 8 and that the corresponding update needs to be made to generate_copy_rules. I don't have time to dig deeper at the moment though.

@maehler
Copy link
Collaborator

maehler commented Mar 5, 2024

Found a post on stackoverflow that claims that you can use a different syntax for generating dynamic rules, and I imagine that this would make things much more portable. Really cool if that works!

Example:

config = {'person1': 'Amy', 'person2': 'Bruce'}

def create_rule(thiskey, thisperson):
    rule:
        name: f"{thisperson}s_rule"
        output: f"{thiskey}.txt"
        run:
            print(f'\n{thiskey} is called {thisperson}!\n')

# Generate rules
for thiskey, thisperson in config.items():
    create_rule(thiskey, thisperson)

rule people:
    input: [this + '.txt' for this in config.keys()]

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.

3 participants