Skip to content

Instantly share code, notes, and snippets.

@infotroph
infotroph / slurm_array_submit.sh
Created March 11, 2025 21:27
model launcher script to run PEcAn jobs as Slurm arrays
#!/bin/bash
launchdir=$(dirname "$1")
logfile="$launchdir"/slurm_submit_log.txt
if [[ -z ${SLURM_ARRAY_TASK_ID} ]]; then
echo "SLURM_ARRAY_TASK_ID not set. Exiting." >> "$logfile"
exit 1
fi
@infotroph
infotroph / gist:f9fc28c9741d883b4d338576e169acba
Last active August 15, 2024 19:11
Enabling Postgres logging during a PEcAn test run
* build a new local postgis image that wraps mdillon/postgis but invokes `postgres -c log_statement=all` at run
(see ckb-notes/postgis_logging/)
```
docker build -t pecan/postgis:9.5_log -<<EOF
FROM mdillon/postgis:9.5
CMD ["postgres", "-c", "log_statement=all"]
EOF
```
* modify actions files to use pecan/postgis:9.5_log instead of mdillon/postgis:9.5
@infotroph
infotroph / gist:f3b21b7500f24c1d13aa7617acd1776f
Last active June 18, 2024 19:58
Proposed package versioning for PEcAn 1.8.0
package v1.7.2 develop proposed_v1.8.0 notes
PEcAn.all 1.7.2 1.7.2.9000 1.8.0 Only package whose version is strictly tied to the release
PEcAn.allometry 1.7.2 1.7.2 1.7.3 cleanup only
PEcAn.assim.batch 1.7.2 1.7.2.9000 1.8.0 breaking changes in gpeval and mcmc.GP, many fns moved from emulator
PEcAn.BASGRA 1.7.2 1.7.2 1.8.0 adds Yasso support
PEcAn.benchmark 1.7.2 1.7.2 1.7.3 cleanup only
PEcAn.BIOCRO 1.7.2 1.7.2 1.7.3 cleanup only
PEcAn.CABLE 1.7.2 1.7.2 1.7.3 cleanup only
PEcAn.CLM45 1.7.2 1.7.2 1.7.3 cleanup only
PEcAn.DALEC 1.7.2 1.7.2 1.7.3 cleanup only
@infotroph
infotroph / gist:1b666a6ad58f201bb901a5e19a6d8df2
Last active September 15, 2022 17:01
PEcAn docker stack on M1 Mac (POC version)
* built a local ARM tidyverse image (I did this in a tempdir)
- Dockerfile:
```
FROM rocker/r-ver:4.2.1
ENV S6_VERSION=v2.1.0.2
ENV RSTUDIO_VERSION=daily
ENV DEFAULT_USER=rstudio
ENV PANDOC_VERSION=default
ENV PATH=/usr/lib/rstudio-server/bin:$PATH
@infotroph
infotroph / gist:a37850c7cbaeb1b339df97ec7537e350
Created August 17, 2020 21:05
Scaling an 7-state RNG to uniform integers on an arbitrary range
# in R:
rng_7 <- function(n) {
sample(0:6, size = n, replace = TRUE)
}
scale_rng <- function(m, n) {
range <- n - m
n_digits <- ceiling(log10(range) / log10(7))
exponents <- seq(from = n_digits - 1, to = 0)
@infotroph
infotroph / actions-exercises.md
Last active March 4, 2020 12:56
GSoC self-assessment ideas for GitHub Actions

Self-assessment ideas: R package testing + GitHub Actions

If you're new to either GitHub Actions or to CI testing of R packages, here are some exercises that can help you get a sense what's involved so that you can write a well-informed proposal. These are not mandatory, and we won't ask to see the results.

Set up simple GitHub Actions checks on an R package

  1. Pick any R package on GitHub and fork it to your own account. It doesn’t matter who wrote the package or what it does, as long as it doesn’t yet have any Actions configured. If you prefer, you could make a new dummy package instead of forking one.
  2. Add a GitHub Actions workflow that performs package checks on every push. Verify that the build passes reliably.
@infotroph
infotroph / actions.md
Last active March 3, 2020 14:55
Adding GitHub Actions to PEcAn

Adding GitHub Actions to PEcAn: Background info for GSoC 2020 applicants

Chris Black (@infotroph), 2020-02-29

Context

PEcAn is mostly developed by scientists who are skilled at programming but whose main job is not to write software, but rather to answer questions about the world. Therefore when someone has written code that helped them answer a question, we want it to be as easy as possible for them to contribute it to PEcAn without spending undue time worrying about configuring their development toolchain.

> tribble(~"X0.0 cm", ~"X1.5 cm", 1, 2) %>%
+ pivot_longer(
+ cols = everything(),
+ names_pattern = "X([\\d.]+) cm",
+ names_ptypes = list(name=double()))
Error: Lossy cast from `x` <character> to `to` <double>.
Locations: 1
Run `rlang::last_error()` to see where the error occurred.
@infotroph
infotroph / gist:bafb1871a76cbcef20460fdbad3cca26
Created April 10, 2019 10:05
Why does touching a file mark it changed in diff-index but not status? And then why does status mark it unchanged for diff-index?
0> git init
Initialized empty Git repository in /Users/chrisb/git_test/.git/
0> echo "some\ncontent" >> foo.txt
0> git add .
0> git commit -m 'first'
[master (root-commit) 3e1a325] first
1 file changed, 2 insertions(+)
create mode 100644 foo.txt
0> git diff-index HEAD
0> touch foo.txt
@infotroph
infotroph / git-biggest-blobs.md
Last active February 14, 2019 20:44
Find the largest objects in a Git repository

So your Git repository is getting ungainly large. What's causing it? Are the problem files still being updated, or are they the deleted ghosts of old binaries?

git cat-file --batch-check --batch-all-objects --unordered \
  | sort --numeric-sort --key=3 \
  | tail -n10 \
  | xargs -L1 sh -c \
    'pth=`git describe --always $0`; \
 printf "%s %s %s %s\n" $0 $1 $2 $pth'