-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
516 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
source /opt/conda/etc/profile.d/conda.sh | ||
conda activate osm | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
source ${MAMBA_ROOT_PREFIX}/etc/profile.d/conda.sh | ||
conda activate ${ENV_NAME} | ||
exec "\$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
set -e | ||
addgroup --gid ${MAMBA_USER_GID} ${MAMBA_USER} | ||
adduser --uid ${MAMBA_USER_ID} --gid ${MAMBA_USER_GID} --disabled-password --gecos "" ${MAMBA_USER} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
set -e | ||
mkdir -p ${MAMBA_ROOT_PREFIX} | ||
chown -R ${MAMBA_USER}:${MAMBA_USER} ${MAMBA_ROOT_PREFIX} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
eval $(/opt/conda/bin/conda shell.bash hook) | ||
conda activate osm | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
source /opt/conda/etc/profile.d/conda.sh | ||
conda activate osm | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,47 +6,33 @@ jobs: | |
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v3 | ||
- uses: pre-commit/[email protected] | ||
tox-tests: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: [3.9] | ||
|
||
steps: | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Cache pip | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -e .[dev] | ||
- name: Start ScienceBeam Docker container | ||
run: | | ||
docker run -d --rm -p 8070 elifesciences/sciencebeam-parser | ||
- name: Run tests | ||
run: | | ||
tox | ||
- name: Test packaging | ||
run: | | ||
tox -e .package | ||
pytest-suite: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Set up docker caching | ||
uses: actions/cache@v4 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-docker-${{ hashFiles('Dockerfile', '**/compose*yaml', '.docker/*', 'pyproject.toml', 'environment.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-docker- | ||
- name: Build the stack | ||
run: | | ||
docker buildx build --cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,dest=/tmp/.buildx-cache,mode=max --build-arg BUILDKIT_INLINE_CACHE=1 . | ||
docker-compose up -d | ||
env: | ||
DOCKER_BUILDKIT: 1 | ||
- name: Wait for services to be ready | ||
run: sleep 10 # Adjust time as needed for your services | ||
- name: Run pytest | ||
run: docker-compose exec app pytest tests | ||
- name: Tear down the stack | ||
if: always() | ||
run: docker-compose down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
FROM condaforge/mambaforge:24.3.0-0 | ||
SHELL ["/bin/bash", "--login", "-c"] | ||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Install debugging tools | ||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
curl \ | ||
iputils-ping \ | ||
net-tools \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy project files for installation | ||
ENV ENV_NAME=osm | ||
COPY environment.yaml /app | ||
|
||
# Create the environment | ||
RUN conda env create -f environment.yaml | ||
|
||
# Ensure the conda environment is activated | ||
RUN echo "source /opt/conda/etc/profile.d/conda.sh && conda activate osm" | tee -a ~/.bashrc /etc/profile /etc/profile.d/conda.sh /etc/skel/.bashrc /etc/skel/.profile > /dev/null | ||
|
||
RUN R -e '\ | ||
install.packages("roadoi", repos = "http://cran.us.r-project.org"); \ | ||
devtools::install_github("quest-bih/oddpub"); \ | ||
devtools::install_github("cran/crminer"); \ | ||
devtools::install_github("serghiou/metareadr"); \ | ||
devtools::install_github("serghiou/rtransparent")' | ||
|
||
# Copy the project files and install the package | ||
COPY pyproject.toml /app | ||
COPY osm /app/osm | ||
COPY .git /app/.git | ||
|
||
# Install the package in editable mode | ||
RUN pip install -e . | ||
|
||
# Make entrypoint etc. convenient for users | ||
COPY .docker/_entrypoint.sh /usr/local/bin/_entrypoint.sh | ||
ENTRYPOINT ["/usr/local/bin/_entrypoint.sh", "--", "osm"] | ||
CMD ["--help"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
services: | ||
sciencebeam: | ||
ports: | ||
# Forward the port 8070 on the host to the port 8070 on the container for | ||
# convenience during development | ||
- "8070:8070" | ||
app: | ||
volumes: | ||
- .:/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
services: | ||
sciencebeam: | ||
image: elifesciences/sciencebeam-parser | ||
networks: | ||
- app_network | ||
|
||
app: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
depends_on: | ||
- sciencebeam | ||
networks: | ||
- app_network | ||
|
||
networks: | ||
app_network: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: osm | ||
channels: | ||
- conda-forge | ||
- nodefaults | ||
dependencies: | ||
- python=3.11 | ||
- click | ||
- python-dotenv | ||
- ipython | ||
- lxml | ||
- pandas | ||
- pip | ||
- pkginfo | ||
- pre-commit | ||
- pytest | ||
- pytest-cov | ||
- pytest-mock | ||
- requests | ||
- rich | ||
- rpy2 | ||
- ruff=0.5.0 | ||
# Dependencies for rtransparent | ||
- r-crul | ||
- r-devtools | ||
- r-dplyr | ||
- r-furrr | ||
- r-future | ||
- r-globals | ||
- r-hoardr | ||
- r-httpcode | ||
- r-lazyeval | ||
- r-lubridate | ||
- r-magrittr | ||
- r-pbapply | ||
- r-pdftools | ||
- r-plyr | ||
- r-purrr | ||
- r-qpdf | ||
- r-readr | ||
- r-rentrez | ||
- r-rlang | ||
- r-stringr | ||
- r-tibble | ||
- r-tidyr | ||
- r-tidyselect | ||
- r-timechange | ||
- r-tokenizers | ||
- r-triebeard | ||
- r-urltools | ||
- r-utf8 | ||
- r-XML | ||
- r-xml2 | ||
- pip: | ||
- metapub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,27 @@ | ||
from . import _version | ||
import os | ||
|
||
__version__ = _version.version | ||
|
||
def get_version(): | ||
try: | ||
from . import _version | ||
|
||
return _version.version | ||
except ImportError: | ||
generate_version_file() | ||
from . import _version | ||
|
||
return _version.version | ||
|
||
|
||
def generate_version_file(): | ||
import pkg_resources | ||
|
||
version = pkg_resources.get_distribution("osm").version | ||
version_file_content = f"version = '{version}'\n" | ||
|
||
version_file_path = os.path.join(os.path.dirname(__file__), "_version.py") | ||
with open(version_file_path, "w") as version_file: | ||
version_file.write(version_file_content) | ||
|
||
|
||
__version__ = get_version() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import click | ||
|
||
from osm.converters import convert_pdf | ||
|
||
|
||
@click.group() | ||
def osm(): | ||
"""Main command for OSM""" | ||
pass | ||
|
||
|
||
@osm.command() | ||
@click.argument("file_path", type=click.Path(exists=True)) | ||
@click.argument("output_file", type=str) | ||
def rtransparent(file_path, output_file): | ||
"""Processes a biomedical publication. Writes out processed document and associated metrics.""" | ||
convert_pdf(file_path, output_file) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.