Skip to content

Instantly share code, notes, and snippets.

View zkamvar's full-sized avatar
😬

Zhian N. Kamvar zkamvar

😬
View GitHub Profile
@zkamvar
zkamvar / 2025-04-25-dashboard-fixing.sh
Last active April 25, 2025 17:50
Steps I took to fix a dashboard (dramatized)
#!/usr/bin/env bash
wd=$(pwd)
# Clone the hub and the dashboard
git clone https://github.com/reichlab/flu-metrocast.git
git clone https://github.com/reichlab/metrocast-dashboard.git
# Temporarily place the ptc/data and predevals/data branches as
# sub-directories of the dashboard. This allows us to quickly
# preview the changes using the site builder
@zkamvar
zkamvar / 2025-04-24-dashboard-demo.sh
Last active May 5, 2025 23:47
hub dashboard demonstration
#!/usr/bin/env bash
set -eo pipefail
#
# PURPOSE:
# This script demonstrates the dashboard workflow process as it
# exists **independent of GitHub workflows**. This script is not
# concerned about where data are stored or when they are updated.
#
# RATIONALE:
# Building a dashboard website requires three tools:
@zkamvar
zkamvar / get-tag-commit.sh
Last active March 24, 2025 19:38
Replace tagged action with a commit hash
#!/usr/bin/env bash
if ! type gh > /dev/null; then
echo "github CLI (gh) must be installed"
exit 1
fi
action=${1}
if [ -z "$action" ]; then
echo "Replace a tagged action with a commit hash"
@zkamvar
zkamvar / 2025-01-17-schema-v5.md
Last active January 21, 2025 14:11
🆕 Schemas v5 release on 2025-01-17

On 2025-01-17, the hubverse development team released the v5 schemas.

This release contains the following changes:

  • Added explicit checks of round_id format through a regex pattern check to the round.round_id property when round.round_id_from_variable is false. This provides upfront validation of the expected format of manually-supplied round IDs (i.e. those not sourced from a task ID) (hubverse-org/schemas#112).
  • BREAKING CHANGE: Restricted the target_metadata.target_keys object to contain only a single key value pair (if not null). This means that target keys can now only consist of a single value from a single task ID (hubverse-org/schemas#117).
  • BREAKING CHANGE The target_variable and target_outcome properties are removed from the standard Task IDs that can be validated against the schema (hubverse-org/schemas#117).
@zkamvar
zkamvar / hubverse-convert-v4.R
Created November 21, 2024 22:57
convert v4
# NOTE: this is a WIP. It does not yet work.
library(hubAdmin)
library(hubUtils)
library(glue)
tasks <- read_config(".", "tasks")
transform_to_v4 <- function(this_output_type, kind = 1, task = 1, round = 1) {
if (kind == "sample") {
class(this_output_type) <- "output_type_item"
@zkamvar
zkamvar / 2024-11-05-update-contributing.R
Created November 7, 2024 14:19
2024-11-05-update-contributing.R
library(gert)
library(tinkr) # pak::pak("ropensci/tinkr#119")
library(xml2)
here::i_am("2024-11-05-update-contributing.R")
#' Update the CONTRIBUTING.md for a given hubverse package
#'
#' This function will update some of the steps in the CONTRIBUTING to add a link to the
#' PR checklist, update the usethis code example, and clarify that the development version
#' will have "development version" as the header for the NEWS
#!/usr/bin/env bash
#
# This will search GitHub for hubs that use quantiles, CDF, or PMF output
# types and check if they use "optional" in their hub-config/tasks.json
# files.
echo "======== SEARCHING GITHUB ============"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $(gh auth token)" \
-H "X-GitHub-Api-Version: 2022-11-28" \
@zkamvar
zkamvar / announcement.md
Last active August 30, 2024 19:01
Updating installation instructions and release process for R packages

Last month, I opened a discussion to formalize R package release process guidelines and it has been approved by the core devs of the Hubverse development team. The most visible change is how you will install hubverse packages. You should no longer use remotes::install_github().

To install ALL hubverse packages, you can use:

install.packages("hubverse", repos = c("https://hubverse-org.r-universe.dev", "https://cran.r-project.org"))

Timeline

@zkamvar
zkamvar / give_thanks.R
Created November 21, 2023 23:43
Give thanks to contributors of a project
#' Produce a list of all GitHub contributors to a project
#'
#' If you want a way to give thanks to specific people who have contributed to a project
#' since a given release, this will extract the GitHub user names from a given package's
#' NEWS file. This assumes that 1) the package has a `NEWS.md` file and 2) the package
#' uses level 1 headers and semantic versioning for each version in the news file.
#'
#' @param package the name of a package
#' @param since a version number (must match a version recorded in the NEWS)
#' @return a character vector with GitHub user names
@zkamvar
zkamvar / fix-file-in-repo.R
Created August 28, 2023 22:33
fix a single file in a repo
library("gh")
library("base64enc")
# get a file from a repository
get_repo_file <- function(org = "carpentries", lesson = "sandpaper-docs", file = "CONTRIBUTING.md", ...) {
gh("GET /repos/{org}/{lesson}/contents/{file}",
.params = list(
org = org,
lesson = lesson,
file = file