Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
snichol2 authored Oct 10, 2023
0 parents commit 52b89b8
Show file tree
Hide file tree
Showing 21 changed files with 54,074 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/docker-management.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Candace Savonen Oct 2021

name: Docker management

on:
pull_request:
branches:
- 'main'
paths: [ docker/Dockerfile ]
# This makes it so you can run your github action manually if you choose
workflow_dispatch:
inputs:
dockerhubpush:
# We can provide an option to set (we will use this later)
description: 'Push to Dockerhub?'
required: true
default: 'false'
jobs:
docker-management:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

# Set up Docker build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# Setup layer cache
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# Set up Docker build
- name: Set up Docker Build
uses: docker/setup-buildx-action@v1

# Build the image based on the Dockerfile
- name: Build Python Docker image
uses: docker/build-push-action@v2
with:
push: false
load: true
# What directory should this be building from?
context: docker
# Where's the Dockerfile to build this image from?
file: docker/Dockerfile
# What should this docker image be called once we are done?
tags: jhudsl/reproducible-r

# Login to Dockerhub
- name: Login to DockerHub
if: ${{ github.event.inputs.dockerhubpush != 'false' }}
uses: docker/login-action@v1
with:
# You will need to set up GitHub secrets with your Docker login info
# for this to work.
# https://docs.github.com/en/actions/security-guides/encrypted-secrets
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Push the Docker image if set to true from a manual trigger
- name: Push Docker image if manual trigger set to true
# This has an if statement so it will only run it we set dockerhubpush to
# something not `false` which is the default
if: ${{ github.event.inputs.dockerhubpush != 'false' }}
run: docker push jhudsl/reproducible-r
46 changes: 46 additions & 0 deletions .github/workflows/run-r-notebook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Candace Savonen Oct 2021

name: Render R Example

# Controls when the action will run. Triggers the workflow on push
# events only for the master branch
on:
# This makes it so you can run your github action manually if you choose
workflow_dispatch:
# This is set to run when any pull request is opened to main
pull_request:
branches: [ main ]

jobs:
render-notebooks:
# This specifies the docker image it should run on
runs-on: ubuntu-latest

steps:
# We need to tell github actions to use the code on the branch we are on
- name: checkout
uses: actions/checkout@v2
with:
# How deep should it fetch?
fetch-depth: 0

# Run R analysis
- name: Run R analysis example
# Here we are telling Docker to run a single command and providing our files
# with the --mount argument. We are telling it to run on the jhudsl/reproducible-r
# docker image, and then the command we would like to run is `bash run_analysis.sh`
run: |
docker run \
--mount type=bind,target=/home/rstudio,source=$PWD \
jhudsl/reproducible-r \
bash run_analysis.sh
- name: Commit rendered R example files
# After it runs the analysis, we are having any changed files to be directly
# committed to the branch we are working from
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add -A
git commit -m 'Render R example' || echo "No changes to commit"
git push origin || echo "No changes to push"
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# History files
.Rhistory
.Rapp.history

# Session Data files
.RData
.DS_Store

# User-specific files
.Ruserdata

# Example code in package build process
*-Ex.R

# Output files from R CMD build
/*.tar.gz

# Output files from R CMD check
/*.Rcheck/

# RStudio files
.Rproj.user/

# produced vignettes
vignettes/*.html
vignettes/*.pdf

# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
.httr-oauth

# knitr and R markdown default cache directories
*_cache/
/cache/

# Temporary files created by R markdown
*.utf8.md
*.knit.md

# R Environment Variables
.Renviron
.Rprofile

# Ignore renv files
.local/
.rstudio/
31 changes: 31 additions & 0 deletions 00-download-data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# C. Savonen 2021

# https://alexslemonade.github.io/refinebio-py/quickstart.html

import os
from pathlib import Path
import pyrefinebio

data_dir = Path('data/SRP070849')

data_file = Path(os.path.join(data_dir, 'SRP070849.tsv'))

metadata_file = Path(os.path.join(data_dir, 'metadata_SRP070849.tsv'))

try:
os.mkdir(data_dir, mode = 0o777)
except OSError as error:
print(error)

if not data_file.exists() or not metadata_file.exists():

print("Downloading SRP070849 from refine.bio")

pyrefinebio.create_token(agree_to_terms=True, save_token=False)

pyrefinebio.download_dataset(
"data/dataset.zip",
"[email protected]",
experiments=["SRP070849"],
extract=True
)
Loading

0 comments on commit 52b89b8

Please sign in to comment.