Skip to content

Commit

Permalink
Merge pull request #115 from nf-osi/develop
Browse files Browse the repository at this point in the history
Redo without squash merge.
  • Loading branch information
allaway authored Feb 24, 2022
2 parents e916846 + 11ecdc2 commit 7cdf0e6
Show file tree
Hide file tree
Showing 36 changed files with 983 additions and 1,425 deletions.
7 changes: 5 additions & 2 deletions .Rprofile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
)
)
}

# no needed if R >= 4.0.0
options(stringsAsFactors = FALSE)
source("renv/activate.R")

# for local development
# change port number associated with your client, here
if (interactive()) options(shiny.port = 8100)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: 'Bug report (app) '
about: 'Create a report to help us improve the app. '
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
Expand All @@ -20,10 +20,15 @@ Steps to reproduce the behavior:
**Expected behavior**
A clear and concise description of what you expected to happen.

**Priority** (select one)
- [ ] Minor ⬇️
- [ ] Major 📢
- [ ] Critical 🆘

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
**Desktop (if applicable, please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Expand Down
16 changes: 13 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
=======
labels: ''
assignees: ''

---
Expand All @@ -13,8 +14,17 @@ A clear and concise description of what the problem is. Ex. I'm always frustrate
**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**How important is this feature?** Select from the options below:
• 🏝 Low - it's an enhancement but not crucial for work
• 🌗 Medium - can do work without it; but it's important (e.g. to save time or for convenience)
• 🌋 Important - it's a blocker and can't do work without it

**When will use cases depending on this become relevant?** Select from the options below:
• Short-term - 2-4 weeks
• Mid-term - 2-4 months
• Long-term - 6 months - 1 year

**Additional context**
Add any other context or screenshots about the feature request here.
**Additional context**
Add any other context or screenshots about the feature request here.
42 changes: 42 additions & 0 deletions .github/schematic_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# During the github workflow to auto deploy the app
# This config file will be used to overwrite the config.yml in the schematic folder
#
# Please modify the configuration values based on your project

# Do not change the 'definitions' section unless you know what you're doing
definitions:
synapse_config: '.synapseConfig'
creds_path: 'credentials.json'
token_pickle: 'token.pickle'
service_acct_creds: 'schematic_service_account_creds.json'

synapse:
master_fileview: 'syn16858331' # fileview of project with datasets on Synapse
manifest_folder: 'manifests' # manifests will be downloaded to this folder
manifest_filename: 'synapse_storage_manifest.csv' # name of the manifest file in the project dataset
token_creds: 'syn21088684' # synapse ID of credentials.json file
service_acct_creds: 'syn25171627' # synapse ID of service_account_creds.json file

manifest:
title: 'NF'
data_type:
- 'NF'

model:
input:
download_url: 'https://raw.githubusercontent.com/nf-osi/nf-metadata-dictionary/v3.0.2/NF.jsonld' # url to download JSON-LD data model
location: 'data-models/NF.jsonld' # path to JSON-LD data model
file_type: 'local' # only type "local" is supported currently

style:
google_manifest:
req_bg_color:
red: 0.9215
green: 0.9725
blue: 0.9803
opt_bg_color:
red: 1.0
green: 1.0
blue: 0.9019
master_template_id: '1LYS5qE4nV9jzcYw5sXwCza25slDfRA1CIg3cs-hCdpU'
strict_validation: false
31 changes: 31 additions & 0 deletions .github/set_gh_secrets.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# require github cli package - 'gh': https://cli.github.com/manual/

args <- commandArgs(trailingOnly = TRUE)

repo <- basename(Sys.getenv("PWD"))

if (repo %in% c("schematic", "data-models")) stop("You are not in the data curator folder !!!")

secret_lists <- yaml::yaml.load_file(toString(args[1]))$definitions
message("Assuming all definition files are stored in the schematic folder ...")

for (f in c("synapse_config", "creds_path", "service_acct_creds")) {
system(
sprintf(
"gh secret set %s < %s",
toupper(paste0("schematic_", f)), file.path("schematic", secret_lists[f])
)
)
}

# token.pickle is a binary file
# If you want to manually add to the secret:
# 1. copy below code snippet and run it in the terminal
# 2. copy content from 'token.pickle.b64' to your github secret
system(
"
less schematic/token.pickle | base64 --wrap=0 > schematic/token.pickle.b64;
gh secret set SCHEMATIC_TOKEN_PICKLE < schematic/token.pickle.b64;
"
)
unlink("schematic/token.pickle.b64")
108 changes: 108 additions & 0 deletions .github/workflows/shinyapps_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help

name: shiny-deploy

# TODO: remove `shiny-server-develop` when we use shinyapps.io as production site
# also consider to change shiny-server-main to main since we will not host in shinyServer
on:
push:
branches:
- develop # add develop for testing for now
tags:
- release*
paths-ignore:
- .github/ISSUE_TEMPLATE/**

jobs:
shiny-deploy:
runs-on: ubuntu-latest
# This image seems to be based on rocker/r-ver which in turn is based on debian
container: rocker/rstudio
env:
# This should not be necessary for installing from public repo's however remotes::install_github() fails without it.
GITHUB_PAT: ${{ secrets.REPO_PAT }}

steps:
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y pip python3.8-venv libcurl4-openssl-dev
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-pandoc@v1

- name: Create and Activate Python Virtual Environment
shell: bash
run: |
python3 -m venv .venv
chmod 755 .venv/bin/activate
source .venv/bin/activate
- name: Install R Packages Dependencies
run: |
R -f install-pkgs.R
- name: Install Python Packages Dependencies
shell: bash
run: |
source .venv/bin/activate
pip3 install -r requirements.txt
- name: Install Schematic
shell: bash
run: |
source .venv/bin/activate
# use 'poetry' to install schematic from the develop branch
pip3 install poetry
git clone --single-branch --branch develop https://github.com/Sage-Bionetworks/schematic.git
cd schematic
poetry build
pip3 install dist/schematicpy-1.0.0-py3-none-any.whl
- name: Set Configurations for Schematic
shell: bash
run: |
source .venv/bin/activate
# download data model to the correct location
R -e '
config <- yaml::yaml.load_file(".github/schematic_config.yml");
url <- config$model$input$download_url;
path <- config$model$input$location;
system(sprintf("mkdir -p %s", dirname(path)));
system(sprintf("wget %s -O %s", url, path));
'
# overwrite the config.yml in schematic
mv -f .github/schematic_config.yml schematic/config.yml
# write out configuration files using github secrets
echo "${{ secrets.SCHEMATIC_SYNAPSE_CONFIG }}" > schematic/.synapseConfig
echo "${{ secrets.SCHEMATIC_SERVICE_ACCT_CREDS }}" > schematic/schematic_service_account_creds.json
echo "${{ secrets.SCHEMATIC_CREDS_PATH }}" > schematic/credentials.json
echo "${{ secrets.SCHEMATIC_TOKEN_PICKLE }}" | base64 -d > schematic/token.pickle
- name: zip virtual env
shell: bash
# ShinyApps has a limit of 7000 files, far exceeded by the many Python dependencies
# that this app' has. As a workaround we zip the virtual environment and later
# unzip it in 'global.R'
run: |
zip -rm .venv.zip .venv
- name: Authorize and deploy app
shell: Rscript {0}
run: |
branch <- Sys.getenv("GITHUB_REF_NAME")
repo <- Sys.getenv("GITHUB_REPOSITORY")
appName <- strsplit(repo, "/")[[1]][2]
if (!startsWith(branch, "release")) {
appName <- paste(appName, "staging", sep = "-")
}
rsConnectUser <- "${{ secrets.RSCONNECT_USER }}"
rsConnectToken <- "${{ secrets.RSCONNECT_TOKEN }}"
rsConnectSecret <- "${{ secrets.RSCONNECT_SECRET }}"
# create config file
config <- "CLIENT_ID: ${{ secrets.OAUTH_CLIENT_ID }}"
config <- c(config, "CLIENT_SECRET: ${{ secrets.OAUTH_CLIENT_SECRET }}")
appUrl <- sprintf("https://%s.shinyapps.io/%s", rsConnectUser, appName)
config <- c(config, sprintf("APP_URL: %s", appUrl))
configFileConn <- file("oauth_config.yml")
tryCatch(
writeLines(config, configFileConn),
finally=close(configFileConn)
)
rsconnect::setAccountInfo(rsConnectUser, rsConnectToken, rsConnectSecret)
rsconnect::deployApp(appName = appName)
20 changes: 11 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.RData
.Rhistory
.Rproj.user/
.DS_Store
HTAN_test_shiny.Rproj
app.bak.R
get_manifest_anno.R
Expand All @@ -9,14 +10,15 @@ www/bootstrap.css
www/bootstrap.min.css
www/getdata.js
www/message-handler.js
files/synapse_storage_manifest.csv
tmp/synapse_storage_manifest.csv
.Rproj.user
schematic/schema_explorer/__pycache__/*
schematic/__pycache__/*
schematic/.DS_Store
schematic/credentials.json
schematic/token.pickle
credentials.json
token.pickle
schematic/
**/credentials.json
**/schematic_service_account_creds.json
**/token.pickle
**/__pycache__
config.yaml
oauth_config.yml
.project
.settings/**
.venv
data-models/
Loading

0 comments on commit 7cdf0e6

Please sign in to comment.