Skip to content

Commit

Permalink
Merge pull request #115 from cokelaer/main
Browse files Browse the repository at this point in the history
Update to be poetry2 compatible.
  • Loading branch information
cokelaer authored Jan 22, 2025
2 parents 5b092f7 + c779a58 commit f685275
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 32 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
max-parallel: 5
matrix:
python: [3.8, 3.9,'3.10', '3.11']
python: [3.9,'3.10', '3.11']
fail-fast: false


Expand All @@ -43,8 +43,7 @@ jobs:
- name: install package itself
run: |
pip install poetry
pip install kaleido #required on github CI by plotly
poetry install
poetry install --with dev
- name: testing
run: |
Expand Down
18 changes: 15 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,23 @@
.. image:: https://app.codacy.com/project/badge/Grade/9031e4e4213e4e57a876fd5b792b5003
:target: https://app.codacy.com/gh/sequana/sequana_pipetools/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade

.. image:: https://img.shields.io/badge/python-3.9%20|%203.10%20|%203.11-blue
:target: https://www.python.org/
:alt: Python versions

.. image:: http://joss.theoj.org/papers/10.21105/joss.00352/status.svg
:target: http://joss.theoj.org/papers/10.21105/joss.00352
:alt: JOSS (journal of open source software) DOI



:Overview: A set of tools to help building or using Sequana pipelines
:Status: Production
:Issues: Please fill a report on `github <https://github.com/sequana/sequana_pipetools/issues>`__
:Python version: Python 3.8, 3.9, 3.10, 3.11
:Citation: Cokelaer et al, (2017), ‘Sequana’: a Set of Snakemake NGS pipelines, Journal of Open Source Software, 2(16), 352, `JOSS DOI doi:10.21105/joss.00352 <http://www.doi2bib.org/bib/10.21105%2Fjoss.00352>`_

Installation
============
🔧 Installation
===============

from pypi website::

Expand Down Expand Up @@ -312,6 +317,8 @@ Changelog
========= ======================================================================
Version Description
========= ======================================================================
1.2.0 * update to be compatible with poetry 2.0
* print container size when initiating a pipeline
1.1.1 * symlink creation on apptainers skipped if permission error (file
is probably already present and created by another users e.g.
the admin system)
Expand Down Expand Up @@ -427,3 +434,8 @@ Version Description
from sequana.pipeline_common
0.1.X * software creation
========= ======================================================================


## 🗨️ Contacts <a name="contacts"></a>

For questions, feel free to reach out to the maintainers through GitHub.
46 changes: 22 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[build-system]
requires = ["poetry-core>=1.0.0"]
requires = ["poetry-core>=2.0.0"]
build-backend = "poetry.core.masonry.api"


#maintainer ?#maintainer email
[tool.poetry]
[project]
name = "sequana_pipetools"
version = "1.1.1"
version = "1.2.0"
description = "A set of tools to help building or using Sequana pipelines"
authors = ["Sequana Team"]
authors = [{name="Sequana Team", email="thomas.cokelaer@pasteur.fr"}]
license = "BSD-3"
repository = "https://github.com/sequana/sequana_pipetools"
readme = "README.rst"
Expand All @@ -21,7 +20,6 @@ classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -33,28 +31,28 @@ classifiers = [
packages = [
{ include = "sequana_pipetools" }
]
requires-python = ">=3.8,<4.0"
dependencies = [
"easydev >=0.12",
"parse >=1.19.0",
"ruamel.yaml >=0.18.5",
"packaging >=23.1",
"pykwalify >=1.8",
"importlib_resources >=5.4.0",
"pyyaml >=1.3",
"aiohttp >=3.8.4",
"tqdm >=4.65",
"charset-normalizer >=2",
"rich-click >=1.7.1",
"cookiecutter >=2.6.0",
"docutils (>0.20,!=0.21)",
"versionix (>=0.99.2,<0.100.0)"
]

[tool.poetry.dependencies]
python = ">=3.8,<4.0"
easydev = ">=0.12"
parse = ">=1.19.0"
"ruamel.yaml" = ">=0.18.5"
packaging = ">=23.1"
pykwalify = ">=1.8"
importlib_resources = ">=5.4.0"
pyyaml = ">=1.3"
aiohttp = ">=3.8.4"
tqdm = ">=4.65"
charset-normalizer = ">=2"
versionix = ">=0.2.0"
rich-click = "^1.7.1"
docutils = "^0.20"
cookiecutter = "^2.6.0"

[tool.poetry.scripts]
[project.scripts]
sequana_pipetools = "sequana_pipetools.scripts.main:main"


[tool.poetry.group.dev.dependencies]
black = "^23.7.0"
pytest = "^8.0.0"
Expand Down
13 changes: 13 additions & 0 deletions sequana_pipetools/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@ def levenshtein_distance(token1: str, token2: str) -> int:
return distances[len1][len2]


def get_url_file_size(url):
try:
response = requests.head(url, allow_redirects=True)
if response.status_code == 200 and "Content-Length" in response.headers:
return int(response.headers["Content-Length"])
else:
logger.warning(f"Unable to retrieve file size from {url}. Status code:", response.status_code)
return 0
except requests.RequestException as e:
logger.warning(f"Unable to retrieve file size from {url}:", e)
return 0


def url2hash(url):
md5hash = hashlib.md5()
md5hash.update(url.encode())
Expand Down
10 changes: 8 additions & 2 deletions sequana_pipetools/sequana_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from tqdm.asyncio import tqdm

from sequana_pipetools import get_package_version
from sequana_pipetools.misc import url2hash
from sequana_pipetools.misc import get_url_file_size, url2hash
from sequana_pipetools.snaketools.profile import create_profile

from .misc import Colors, PipetoolsException
Expand Down Expand Up @@ -568,6 +568,7 @@ def _download_zenodo_images(self): # pragma: no cover

count = 0
files_to_download = []
total_size = 0

# define the URLs and the output filename.
for url in urls:
Expand All @@ -584,7 +585,7 @@ def _download_zenodo_images(self): # pragma: no cover

try:
Path(linkfile).symlink_to(f"{name}")
except FileExistsError:
except (FileExistsError, PermissionError): # pragma: no cover
pass

container = url.split("/")[-1]
Expand All @@ -596,6 +597,11 @@ def _download_zenodo_images(self): # pragma: no cover
count += 1
logger.info(f"Preparing {url} for download")

total_size += get_url_file_size(url)
total_size /= 1024 * 1024
total_size = round(total_size)
logger.info(f"Total container size (Mb): {total_size}")

try: # try an asynchrone downloads
multiple_downloads(files_to_download)
except (KeyboardInterrupt, asyncio.TimeoutError):
Expand Down

0 comments on commit f685275

Please sign in to comment.