Skip to content

codingfabi/retraction_check

Repository files navigation

retraction_check

Tests Code Quality Build

A Python package to check whether papers in your .bib file or a specific bibtex entry have been listed on Retraction Watch.

Features

  • Parse .bib files and extract paper information
  • Query the Retraction Watch dataset for retracted papers
  • Support both exact DOI matching and fuzzy title matching
  • Robust error handling for various edge cases

Installation

# Install from PyPI (when published)
pip install retraction-check

# Or install from source
git clone https://github.com/codingfabi/retraction_check.git
cd retraction_check
pipenv install

# Install development dependencies
pipenv install --dev

Usage

Command line

# Using the installed command
retraction-check yourfile.bib

# Or using the module
python -m retraction_check.check_bib yourfile.bib

Development

Running tests

# Run all tests
pipenv run test

# Run tests with coverage
pipenv run test-cov

# Run tests in watch mode
pipenv run test-watch

# Run tests directly with Python
python tests/run_tests.py

Code quality

# Format code
pipenv run format

# Lint code
pipenv run lint

# Type checking
pipenv run type-check

# Run all checks
pipenv run check-all

Available test commands

  • test - Run all tests with verbose output
  • test-cov - Run tests with coverage report (HTML and terminal)
  • test-watch - Run tests in watch mode with short traceback
  • lint - Run flake8 linting
  • format - Format code with black
  • format-check - Check if code is properly formatted
  • type-check - Run mypy type checking
  • check-all - Run all quality checks (format, lint, type-check, test-cov)

Requirements

  • Python 3.8+
  • bibtexparser
  • requests

Example: Automated Retraction Check with GitHub Actions

You can automate retraction checks for your bibliography file using GitHub Actions. The following workflow runs the check on demand, on a schedule, or on every commit to a specific branch. If any retractions are found, it will open a GitHub issue listing the findings.

name: Retraction Check

on:
  workflow_dispatch:  # Allows manual trigger
  schedule:
    - cron: '0 8 * * 1'  # Runs every Monday at 08:00 UTC
  push:
    paths:
      - yourfile.bib  # Change this to your personal bib file to make sure the workflow runs every time the bibfile changes

jobs:
  retraction_check:
    runs-on: ubuntu-latest
    permissions:
      issues: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install .

      - name: Run retraction check
        id: retraction
        run: |
          python -m retraction_check.check_bib path/to/your/bibfileyourfile.bib > findings.txt
          grep -v "No retracted papers found." findings.txt > findings_only.txt || true

      - name: Create issue if retractions found
        if: success() && hashFiles('findings_only.txt') != ''
        uses: peter-evans/create-issue-from-file@v5
        with:
          title: "Retraction Watch: Retracted Papers Detected in Bibliography"
          content-filepath: findings_only.txt
          labels: retraction, automated-check
  • Replace yourfile.bib with the path to your bibliography file.
  • The workflow will create an issue only if retractions are found.
  • You can trigger the workflow manually, on a schedule, or on every commit to the specified branch.

Example: Automated Retraction Check with GitLab CI

You can also automate retraction checks for your bibliography file using GitLab CI/CD. The following example runs the check on every push to the default branch and creates an issue if retractions are found (requires a GitLab personal access token with API scope stored as GITLAB_TOKEN).

retraction_check:
  image: python:3.11
  stage: test
  script:
    - pip install .
    - python -m retraction_check.check_bib path/to/yourfile.bib > findings.txt
    - grep -v "No retracted papers found." findings.txt > findings_only.txt || true
    # Only create an issue if findings_only.txt is not empty
    - |
      if [ -s findings_only.txt ]; then
        curl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
             --header "Content-Type: application/json" \
             --data '{
               "title": "Retraction Watch: Retracted Papers Detected in Bibliography",
               "description": "$(cat findings_only.txt)",
               "labels": "retraction, automated-check"
             }' \
             --request POST "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/issues"
      fi
  only:
    - main  # or your default branch
  rules:
    - changes:
        - path/to/yourfile.bib
  • Replace path/to/yourfile.bib with the path to your bibliography file.
  • Store a GitLab personal access token with API scope as a CI/CD variable named GITLAB_TOKEN.
  • The job will create an issue only if retractions are found and the .bib file changes.

About

A python package to check whether a paper in your .bib file has been listed on retraction watch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published