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

Add option to update modules with linting #1588

Merged
merged 38 commits into from
Jun 2, 2022
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c5c1901
don't updatate sha if the module is not updated
Apr 19, 2022
f26c2d4
modify changelog
Apr 20, 2022
eb972a7
Merge branch 'dev' into update_modules
mirpedrol Apr 20, 2022
f3058b4
Merge branch 'dev' into update_modules
ggabernet May 5, 2022
2374756
don't updatate sha if the module is not updated
Apr 19, 2022
5b04b2b
resolve conflicts in changelog
Apr 20, 2022
e6b1af5
resolve conflicts in main_nf.py
mirpedrol May 16, 2022
cee29f0
fix conflicts
mirpedrol May 17, 2022
21d9a54
get version and build
mirpedrol May 17, 2022
db7fac1
check that url exist & add log info
mirpedrol May 17, 2022
72c49c9
improve logging
mirpedrol May 17, 2022
008350e
improve comments
mirpedrol May 17, 2022
4c87e9d
fix conflicts
mirpedrol May 17, 2022
e152b7b
remove changes made by error
mirpedrol May 17, 2022
52a60ab
merge branch
mirpedrol May 17, 2022
106b60e
update changelog
mirpedrol May 17, 2022
9d839cd
Merge branch 'dev' into update_modules
mirpedrol May 17, 2022
c1c4541
small changelog change
mirpedrol May 17, 2022
e6525ef
improve debug messages
mirpedrol May 19, 2022
faef8ea
Merge branch 'dev' into update_modules
mirpedrol May 30, 2022
0122056
don't updatate sha if the module is not updated
Apr 19, 2022
b288578
resolve conflicts in changelog
Apr 20, 2022
7b1538e
resolve conflicts in main_nf.py
mirpedrol May 16, 2022
ef00ede
fix conflicts
mirpedrol May 17, 2022
f205b15
get version and build
mirpedrol May 17, 2022
877b6f6
resolve rebase conflicts
mirpedrol Jun 2, 2022
3886ad1
improve logging
mirpedrol May 17, 2022
eac514d
improve comments
mirpedrol May 17, 2022
a5ba612
remove changes made by error
mirpedrol May 17, 2022
08e1b94
don't updatate sha if the module is not updated
Apr 19, 2022
99bf430
resolve rebase conflicts
mirpedrol Jun 2, 2022
550f6d2
improve debug messages
mirpedrol May 19, 2022
af8e030
resolve conflicts
mirpedrol Jun 2, 2022
3e9076c
refactor fix flag to fix-version
mirpedrol Jun 2, 2022
8e061f1
fix typo in CHANGELOG.md
mirpedrol Jun 2, 2022
0037bf9
Remove duplicate in CHANGELOG.md
mirpedrol Jun 2, 2022
cfcf3b6
Remove changed made by mistake
mirpedrol Jun 2, 2022
358bb0a
fix black linting
mirpedrol Jun 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
check that url exist & add log info
mirpedrol committed May 17, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit db7fac1e3b05d1b5adac7ac5501c13604edc6519
70 changes: 51 additions & 19 deletions nf_core/modules/lint/main_nf.py
Original file line number Diff line number Diff line change
@@ -5,10 +5,14 @@

import re
import nf_core
import logging
import requests

from galaxy.tool_util.deps.mulled.util import build_target
import nf_core.modules.module_utils

log = logging.getLogger(__name__)


def main_nf(module_lint_object, module, fix_version):
"""
@@ -211,7 +215,6 @@ def check_process_section(self, lines, fix_version):
singularity_tag = "singularity"
docker_tag = "docker"
bioconda_packages = []
update = False

# Process name should be all capital letters
self.process_name = lines[0].split()[1]
@@ -275,17 +278,31 @@ def check_process_section(self, lines, fix_version):
last_ver = response.get("latest_version")
if last_ver is not None and last_ver != bioconda_version:
package, ver = bp.split("=", 1)
self.warned.append(
("bioconda_latest", f"Conda update: {package} `{ver}` -> `{last_ver}`", self.main_nf)
)
update = True
# If a new version is available and fix is True, update the version
if fix_version:
if _fix_module_version(self, bioconda_version, last_ver, singularity_tag, response):
log.info(f"Updating package {package} `{ver}` -> `{last_ver}`")
log.debug(f"Updating package {package} `{ver}` -> `{last_ver}`")
self.passed.append(
(
"bioconda_latest",
f"Conda package has been updated to the latest available: `{bp}`",
self.main_nf,
)
)
else:
log.debug(f"Unable to updating package {package} `{ver}` -> `{last_ver}`")
self.warned.append(
("bioconda_latest", f"Conda update: {package} `{ver}` -> `{last_ver}`", self.main_nf)
)
else:
self.warned.append(
("bioconda_latest", f"Conda update: {package} `{ver}` -> `{last_ver}`", self.main_nf)
)
else:
self.passed.append(("bioconda_latest", f"Conda package is the latest available: `{bp}`", self.main_nf))

if docker_tag == singularity_tag:
# If linting was successful and a new version is available and fix is True
if fix_version and update:
_fix_module_version(self, bioconda_version, last_ver, singularity_tag, response)
return True
else:
return False
@@ -357,19 +374,34 @@ def _fix_module_version(self, current_version, latest_version, singularity_tag,

with open(self.main_nf, "r") as source:
lines = source.readlines()

# Check if the new version + build exist and replace
new_lines = []
for line in lines:
l = line.strip(" '\"")
build_type = _container_type(l)
if build_type == "bioconda":
new_lines.append(re.sub(rf"{current_version}", f"{latest_version}", line))
elif build_type == "singularity" or build_type == "docker":
# Check that the new url is valid
new_url = re.search(
"(?:')(.+)(?:')", re.sub(rf"{singularity_tag}", f"{latest_version}--{build}", line)
).group(1)
response_new_container = requests.get(
"https://" + new_url if not new_url.startswith("https://") else new_url, stream=True
)
if response_new_container.status_code != 200:
return False
new_lines.append(re.sub(rf"{singularity_tag}", f"{latest_version}--{build}", line))
else:
new_lines.append(line)

# Replace outdated versions by the latest one
with open(self.main_nf, "w") as source:
for line in lines:
l = line.strip(" '\"")
build_type = _container_type(l)
if build_type == "bioconda":
source.write(re.sub(rf"{current_version}", f"{latest_version}", line))
elif build_type == "singularity" or build_type == "docker":
source.write(re.sub(rf"{singularity_tag}", f"{latest_version}--{build}", line))
else:
source.write(line)
### CHECK URLS BEFORE WRITING
### MOVE FUNCTION CALL UPPER TO WRITE LOG & DEBUG MESSAGES
for line in new_lines:
source.write(line)

return True


def _get_build(response):