Skip to content

Commit

Permalink
Fix FTP URLs for PRIDE and MassIVE (#31)
Browse files Browse the repository at this point in the history
* Fixed links for all the things

* Fix most linting errors

* Migrate to Ruff

* Used Ruff to reformat

* Change branch target

* Update test action

* Migrate to pyproject.toml

* Bump changelog

* Add codecov token
  • Loading branch information
wfondrie authored Apr 16, 2024
1 parent 34cfc48 commit aa1a0aa
Show file tree
Hide file tree
Showing 28 changed files with 276 additions and 197 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/black.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Lint

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install Ruff
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Lint with Ruff
run: |
ruff check . --output-format=github
- name: Check formatting with Ruff
run: |
ruff format --check .
13 changes: 4 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,21 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov wheel
pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Run unit and system tests
run: |
pytest --cov=ppx tests/
- name: Upload coverage to codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
23 changes: 18 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0 # Replace by any tag/version: https://github.com/psf/black/tags
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: detect-private-key
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.7
hooks:
# Run the linter.
- id: ruff
types_or: [ python, pyi, jupyter ]
args: [ --fix, --show-fixes ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
33 changes: 19 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# Changelog for ppx

## [Unreleased]
## [1.4.0]
### Changed
- Linting and formatting is now performed with Ruff.
- Migrated to pyproject.toml based build.

### Fixed
- Fixed MassIVE FTP URLs using the MassIVE PROXI API.
- Fixed PRIDE FTP URLs... again.
- Updated unit tests with new PRIDE FTP URLs.

## [1.3.0] - 2022-04-39
### Added
- Support for cloud provider destinations. Thanks @sooheon!
- Support for cloud provider destinations. Thanks @sooheon!

## [1.2.6] - 2022-03-16
### Fixed
Expand Down Expand Up @@ -45,25 +51,25 @@

## [1.2.0] - 2021-09-14
### Added
- New `timeout` parameter for most functions and classes. This specifies the
- New `timeout` parameter for most functions and classes. This specifies the
maximum amount of time to wait for a response from the server.

### Changed
- The backend for MassIVE now uses the GNPS API to list files and projects,
only falling back to scraping the FTP server on failure. This should make
only falling back to scraping the FTP server on failure. This should make
it much faster. Thanks @mwang87!
- Files and projects are now returned in sorted order.

### Fixed
- Poor connections with PRIDE were leading to a number of occasional errors.
Multiple reconnect attempts are now tried for a wider variety of FTP
- Poor connections with PRIDE were leading to a number of occasional errors.
Multiple reconnect attempts are now tried for a wider variety of FTP
operations.

## [1.1.1] - 2021-07-02
### Fixed
- Downloading files is now more robust. ppx will now retry FTP connections up
to 10 times if the connection was dropped or refused.
- Partial downloads are now continued automatically by comparing the local
- Partial downloads are now continued automatically by comparing the local
file size to the remote file size.

## [1.1.0] - 2021-05-18
Expand All @@ -73,26 +79,25 @@
instead. **Note that this may change the number, identity, and order of the
file that were previously returned for PRIDE projects!**
- Small documentation updates.

### Added
- Caching of the remote files and directories found for a project. If a
- Caching of the remote files and directories found for a project. If a
project's `fetch` attribute is `False`, then we'll rely on this cached
data, so long as it is available. Setting `fetch=True` will always refresh
the data from the repository.

## [1.0.0] - 2021-05-14
### Changed
## [1.0.0] - 2021-05-14
### Changed
- **We did a complete rework of the API!** This will break nearly all previous
code using ppx, but greatly improves its versatility.
See the [docs](https://ppx.readthedocs.io) for more details
- Updated the build to align with
[PEP517](https://www.python.org/dev/peps/pep-0517/)

### Added
- A command line interface for downloading files from PRIDE and MassIVE
- A command line interface for downloading files from PRIDE and MassIVE
projects.
- Additional unit tests.
- A ppx logo
- This changelog.
- ppx is now available on bioconda!

3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
Expand All @@ -13,8 +12,8 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
import subprocess
import sys

sys.path.insert(0, os.path.abspath(".."))

Expand Down
12 changes: 6 additions & 6 deletions ppx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
"""See the README for detailed documentation and examples."""

try:
from importlib.metadata import version, PackageNotFoundError
from importlib.metadata import PackageNotFoundError, version

try:
__version__ = version(__name__)
except PackageNotFoundError:
pass

except ImportError:
from pkg_resources import get_distribution, DistributionNotFound
from pkg_resources import DistributionNotFound, get_distribution

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
pass

from . import pride
from . import massive
from . import massive, pride
from .config import get_data_dir, set_data_dir
from .factory import find_project
from .pride import PrideProject
from .massive import MassiveProject
from .config import get_data_dir, set_data_dir
from .pride import PrideProject
6 changes: 5 additions & 1 deletion ppx/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This module contains the configuration details for ppx"""
import os

import logging
import os
from pathlib import Path

from cloudpathlib import AnyPath
Expand All @@ -14,6 +15,7 @@ class PPXConfig:
Attributes
----------
path : pathlib.Path object
"""

def __init__(self):
Expand Down Expand Up @@ -61,6 +63,7 @@ def _resolve_path(path):
-------
Path or CloudPath
The resolved path.
"""
path = AnyPath(path)
try:
Expand All @@ -83,6 +86,7 @@ def set_data_dir(path=None):
----------
path : str or pathlib.Path object, optional
The path for ppx to use as its data directory.
"""
config.path = path

Expand Down
25 changes: 14 additions & 11 deletions ppx/factory.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
"""The PXDataset class and its associated methods.
This is the foundation of the ppx package.
"""
This module contains the PXDataset class and its associated methods,
which are the foundation of the ppx package.
"""
import re

import logging
import re
from urllib.parse import urlparse

import requests

from .pride import PrideProject
from .massive import MassiveProject
from .pride import PrideProject

LOGGER = logging.getLogger(__name__)

Expand All @@ -29,6 +30,7 @@ class PXDFactory:
Should ppx check the remote repository for updated metadata?
timeout : float, optional
The maximum amount of time to wait for a server response.
"""

rest = "http://proteomecentral.proteomexchange.org/cgi/GetDataset"
Expand Down Expand Up @@ -77,11 +79,11 @@ def id(self):

def find(self):
"""Find the dataset at the partner repository"""
kwargs = dict(
local=self._local,
fetch=self._fetch,
timeout=self._timeout,
)
kwargs = {
"local": self._local,
"fetch": self._fetch,
"timeout": self._timeout,
}

if self._repo == "PRIDE":
return PrideProject(self._repo_id, **kwargs)
Expand Down Expand Up @@ -156,13 +158,14 @@ def find_project(identifier, local=None, repo=None, fetch=False, timeout=10.0):
-------
:py:class:`~ppx.PrideProject` or :py:class:`~ppx.MassiveProject`
An object to interact with the project data in the repository.
"""
identifier = str(identifier).upper()
if repo is not None:
repo = str(repo).lower()

# User-specified:
kwargs = dict(local=local, fetch=fetch, timeout=timeout)
kwargs = {"local": local, "fetch": fetch, "timeout": timeout}
if repo == "pride":
return PrideProject(identifier, **kwargs)

Expand Down
Loading

0 comments on commit aa1a0aa

Please sign in to comment.