<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.2">Jekyll</generator><link href="https://dgorhe.github.io/blog/feed.xml" rel="self" type="application/atom+xml" /><link href="https://dgorhe.github.io/blog/" rel="alternate" type="text/html" /><updated>2022-11-06T16:14:31+00:00</updated><id>https://dgorhe.github.io/blog/feed.xml</id><title type="html">Know Thyself</title><subtitle>I'm a pathologically curious person and an aspiring data scientist. If you have suggestions, feel free to email me. If any of the information looks incorrect, send me a source to what  you believe is the correct information and I'll take a look and change the post accordingly.</subtitle><entry><title type="html">Using Columbia University’s Ginsburg HPC</title><link href="https://dgorhe.github.io/blog/educational/2022/10/28/How-To-Use-Ginsburg.html" rel="alternate" type="text/html" title="Using Columbia University’s Ginsburg HPC" /><published>2022-10-28T20:00:00+00:00</published><updated>2022-10-28T20:00:00+00:00</updated><id>https://dgorhe.github.io/blog/educational/2022/10/28/How-To-Use-Ginsburg</id><content type="html" xml:base="https://dgorhe.github.io/blog/educational/2022/10/28/How-To-Use-Ginsburg.html">&lt;h1 id=&quot;introduction&quot;&gt;Introduction&lt;/h1&gt;
&lt;p&gt;Ginsburg is the name of Columbia University’s newest high performance computing cluster (HPC). As a Data Science Master’s student at the university I’ve been using Ginsburg for my work in the &lt;a href=&quot;http://jovanoviclab.com/&quot;&gt;Jovanovic Lab&lt;/a&gt;. There’s plenty of very basic stuff in &lt;a href=&quot;https://confluence.columbia.edu/confluence/display/rcs/Ginsburg%3A+Getting+Started&quot;&gt;Ginsburg’s documentation&lt;/a&gt;. I want to cover some more involved things which could improve your quality of life while using or developing code, dramatically decrease the amount of time it takes to run code, or make some things feasible which were previously infeasible.&lt;/p&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;create-an-alias-for-interactive-sessions&quot;&gt;Create an Alias for Interactive Sessions&lt;/h1&gt;
&lt;p&gt;Let’s start with something easy. Oftentimes, we want interactive environments for coding but you need more resources than your local machine has. Ginsburg is useful for this because you can get a &lt;em&gt;lot&lt;/em&gt; of resources (hopefully) quickly and at a moments notice. What’s annoying is that the command might look something like this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;srun --pty -t 0-03:00 -A mjlab --mem=64gb -N 1 -c 32 /bin/bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can look at the &lt;a href=&quot;https://confluence.columbia.edu/confluence/display/rcs/Ginsburg+-+Submitting+Jobs#:~:text=shell%20will%20wait.-,Basic%20Job%20Directives,-The%20following%20table&quot;&gt;documentation&lt;/a&gt; for what each part means, but the bottom-line is that this is extremely annoying to type repeatedly. It’s especially annoying because you probably want the same resources each time you start an interactive session. We can solve this by creating an alias for this command. Open the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bashrc&lt;/code&gt; file in your respective home directory. This file contains a bunch of settings for the shell that Ginsburg shows to you (i.e. the terminal when you login). Use your text editor of choice. In my case, I’ll use vim.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vim ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The file will look something like this&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# &amp;gt;&amp;gt;&amp;gt; conda initialize &amp;gt;&amp;gt;&amp;gt;
# !! Contents within this block are managed by 'conda init' !!
__conda_setup=&quot;$('/burg/opt/anaconda2-2019.10/anaconda2/bin/conda' 'shell.bash' 'hook' 2&amp;gt; /dev/null)&quot;
if [ $? -eq 0 ]; then
    eval &quot;$__conda_setup&quot;
else
    if [ -f &quot;/burg/opt/anaconda2-2019.10/anaconda2/etc/profile.d/conda.sh&quot; ]; then
        . &quot;/burg/opt/anaconda2-2019.10/anaconda2/etc/profile.d/conda.sh&quot;
    else
        export PATH=&quot;/burg/opt/anaconda2-2019.10/anaconda2/bin:$PATH&quot;
    fi
fi
unset __conda_setup
# &amp;lt;&amp;lt;&amp;lt; conda initialize &amp;lt;&amp;lt;&amp;lt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can ignore most stuff but toward the top where all the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;alias ...&lt;/code&gt; commands are, we’ll add our alias. In my case, I’m calling it &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sesh&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias sesh='srun --pty -t 0-03:00 -A mjlab --mem=64gb -N 1 -c 32 /bin/bash'

...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I’m not showing the remainder of the file again to save some space, but I didn’t change or delete any of it. You can always come back and change this, but think of this as a default. Now when you run&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sesh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;you’ll start an interactive session with all the settings you put in that alias.&lt;/p&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;how-to-avoid-typing-your-password-each-time-option-1&quot;&gt;How to Avoid Typing Your Password Each Time (Option 1)&lt;/h1&gt;
&lt;p&gt;This seems like a pretty pedantic thing, but if you’re logging in and out of Ginsburg all the time, it can get pretty annoying. Fortunately there’s a pretty simple solution. Your computer checks a folder called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.ssh/&lt;/code&gt; whenever you login via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt;. Specifically it checks whether a matching key is available on the remote machine. It’s not exactly a copy but the details are not super important.&lt;/p&gt;

&lt;h3 id=&quot;step-1&quot;&gt;Step 1.&lt;/h3&gt;
&lt;p&gt;First we want to check if the key is already available&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ls ~/.ssh/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If the files &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;id_ed25519&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;id_ed25519.pub&lt;/code&gt; are already there, skip to &lt;a href=&quot;#step-3&quot;&gt;Step 3&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;step-2&quot;&gt;Step 2.&lt;/h3&gt;
&lt;p&gt;Assuming the keys are not there, we’ll generate them with the following command&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh-keygen -t ed25519
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Follow the prompts (you can leave everything blank) and it should look something like this.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Generating public/private ed25519 key pair.
Enter file in which to save the key ($HOME/.ssh/id_ed25519):     
Enter passphrase (empty for no passphrase):  
Enter same passphrase again:  
Your identification has been saved in $HOME/.ssh/id_ed25519.
Your public key has been saved in $HOME/.ssh/id_ed25519.pub.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;step-3&quot;&gt;Step 3.&lt;/h3&gt;
&lt;p&gt;Now we want to put the public key onto Ginsburg with the following command. Make sure to replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;UNI&amp;gt;&lt;/code&gt; with your actual UNI. This part will still prompt you to put in your password.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cat ~/.ssh/id_ed25519.pub | ssh &amp;lt;UNI&amp;gt;@ginsburg.rcs.columbia.edu 'cat - &amp;gt;&amp;gt; ~/.ssh/authorized_keys' 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This command basically opens one of the files we just created, sends it over to Ginsburg, and tells Ginsburg to recognize the host computer (i.e. your laptop, desktop, etc) whenever we use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;step-4&quot;&gt;Step 4.&lt;/h3&gt;
&lt;p&gt;Double check that everything works by logging out of Ginsburg (you can just type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exit&lt;/code&gt; and then hit Enter to leave Ginsburg).&lt;/p&gt;

&lt;hr /&gt;
&lt;h1 id=&quot;how-to-avoid-typing-your-password-each-time-option-2&quot;&gt;How to Avoid Typing Your Password Each Time (Option 2)&lt;/h1&gt;
&lt;p&gt;If option 1 doesn’t interest you, there’s another option, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshpass&lt;/code&gt;. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshpass&lt;/code&gt; simply forwards your password to the ssh prompt automatically. If you’re using a public private key pair (i.e. option 1), at some point the remote machine has to read your private key. If you trust the server, this is not an issue, but if you’re not sure, using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshpass&lt;/code&gt; could be more secure. Passwords are typically hashed on the host end (i.e. your laptop, desktop, etc) so you’re never giving your sensitive credentials to the remote machine. However, it seems like the maintainer of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshpass&lt;/code&gt; is no longer actively maintaining the software. This could mean that there are unresolved bugs which could impact the security of the software. Both options are equally as convenient once you set them up.&lt;/p&gt;

&lt;p&gt;The easiest way to install &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshpass&lt;/code&gt; is via Homebrew, a package manager for MacOS. As of writing this, there is no Windows version available. Please look at the Homebrew homepage for instructions on &lt;a href=&quot;https://brew.sh/&quot;&gt;installing Homebrew&lt;/a&gt;. Once you have Homebrew installed, in your terminal simply type:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;brew install hudochenkov/sshpass/sshpass
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Once it’s installed in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bashrc&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.zshrc&lt;/code&gt; add the following alias&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;alias ginsburg='sshpass -p '&amp;lt;PASSWORD&amp;gt;' ssh &amp;lt;UNI&amp;gt;@ginsburg.rcs.columbia.edu'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ginsburg&lt;/code&gt; with whatever alias name you would like. Also, replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;PASSWORD&amp;gt;&lt;/code&gt; with your actual password and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;UNI&amp;gt;&lt;/code&gt; with your actual UNI. With all that set up, when you type in the following and hit enter, you should be logged into the Ginsburg cluster.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ginsburg
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;
&lt;h1 id=&quot;performing-multiple-jobs-concurrently&quot;&gt;Performing Multiple Jobs Concurrently&lt;/h1&gt;
&lt;p&gt;A really common use case in biology labs is performing some time-consuming processing/analysis on multiple files. More generally, sometimes we want to run a program multiple times with different parameters and the inputs of each run are not dependent on the outputs of another run. As a result we don’t care how quickly each thing finishes as long as we don’t have to do them one after another.&lt;/p&gt;

&lt;p&gt;I’ve found the easiest way to do this is to create a template bash script and use python to ‘configure’ each template and submit that configuration as a job. I’ll show this with a concrete example.&lt;/p&gt;

&lt;h3 id=&quot;problem&quot;&gt;Problem&lt;/h3&gt;
&lt;p&gt;We have a bunch of files called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bed&lt;/code&gt; files. We want to annotate them using a program called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;annotator&lt;/code&gt;. However, there are 50 files and each file takes 15-20 minutes to run. If we ran them all one after the other it would take 12-16 &lt;em&gt;hours&lt;/em&gt; to run. Let’s see how we can submit multiple jobs concurrently.&lt;/p&gt;

&lt;h3 id=&quot;solution&quot;&gt;Solution&lt;/h3&gt;
&lt;p&gt;Here is the directory structure of our folder&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;├── submit_jobs.py
├── submit.sh
└── template.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;template.sh&lt;/code&gt; is the file which is actually sent as an individual batch job. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;submit_jobs.py&lt;/code&gt; creates a group of jobs based on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;template.sh&lt;/code&gt;. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;submit.sh&lt;/code&gt; is simply a convenience script for configuring 1 or more groups of jobs. The reason for this structure is that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;submit_job.py&lt;/code&gt; looks at all the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bed&lt;/code&gt; files in a folder. If we want to run multiple folders, we have to run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;submit_job.py&lt;/code&gt; multiple times each with different parameters. If you knew that you only needed to run 1 folder at a time, you could simply type out the contents of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;submit.sh&lt;/code&gt; into your terminal and hit enter. Let’s look at each file in more detail.&lt;/p&gt;

&lt;p&gt;Here is the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;template.sh&lt;/code&gt; file&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#!/bin/sh
#SBATCH --account=mjlab        
#SBATCH --job-name=annotator-single-run
#SBATCH --cpus-per-task 4
#SBATCH --time=01:00:00            
#SBATCH --mem-per-cpu=20G
 
module load anaconda/2-2019.10
source /burg/opt/anaconda2-2019.10/anaconda2/etc/profile.d/conda.sh
conda activate annotator

annotator --input ${INPUT} --output ${OUTPUT} --gtfdb ${GTFDB} --species hg38
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The various &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#SBATCH&lt;/code&gt; lines tell Ginsburg how to identify this job and what kind of resources we want. The middle chunk of lines loads the appropriate version of Anaconda and activates a conda environment we’ve created for the annotator program. Conda is simply a way of creating isolated python containers. Each container is typically only used for one program and it contains only the other programs it depends on to run. So in our case, the old version of annotator requires Python 2.7 and older versions of packages which are stored in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;annotator&lt;/code&gt; conda environment.&lt;/p&gt;

&lt;p&gt;Here is our file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;submit_jobs.py&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import sys
import os 
from argparse import PARSER, ArgumentParser

# Argument parser to decide where to look for inputs, outputs, GTF database, and logs
parser = ArgumentParser()
parser.add_argument(&quot;--input&quot;, help='Directory containing bed files')
parser.add_argument(&quot;--output&quot;, help='Directory to write outputs of annotator')
parser.add_argument(&quot;--logs&quot;, help='Directory to write log files')
parser.add_argument(&quot;--gtfdb&quot;, help='Location of gtfdb')
args = parser.parse_args()

if __name__ == &quot;__main__&quot;:
    # Turn command line arguments into absolute paths
    input = os.path.abspath(args.input)
    output = os.path.abspath(args.output)
    gtfdb = os.path.abspath(args.gtfdb)
    logs = os.path.abspath(args.logs)

    try:
        assert os.path.exists(input) and os.path.exists(output) and os.path.exists(gtfdb) and os.path.exists(logs)
    except AssertionError:
        print(&quot;One of the file paths you entered can't be found&quot;)
        print(&quot;Input absolute path:&quot;, input, &quot;\n&quot;)
        print(&quot;Output path:&quot;, output, &quot;\n&quot;)
        print(&quot;GTFDB absolute path:&quot;, gtfdb, &quot;\n&quot;)
        print(&quot;Logs absolute path:&quot;, logs, &quot;\n&quot;)
        sys.exit(0)
        
    
    # Create lists of absolute paths for inputs and outputs
    bed_files = [os.path.join(input, f) for f in os.listdir(input)]
    output_files = [os.path.join(output, os.path.basename(bed).split(&quot;.&quot;)[:-1][0]) + &quot;.txt&quot; for bed in bed_files]

    # Iterate through each combination of bed file and output file and submit a job
    for bed, out in zip(bed_files, output_files):
        # Take the bed file name, strip the .bed extension and replace it with .log
        logfile = os.path.basename(bed).split('.')[:-1][0] + &quot;.log&quot;
        
        # Turn logfile into an absolute path
        logpath = os.path.join(logs, logfile)
        
        # Build command in components
        command = &quot;sbatch &quot;
        command += f&quot;-A mjlab &quot;
        command += f&quot;-o {logpath} &quot;
        command += f&quot;--export=INPUT={bed},OUTPUT={out},GTFDB={gtfdb} &quot;
        command += f&quot;template.sh&quot;
        os.system(command)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;At the top we initialize an argument parser to read in some command line arguments. Then we check if the file paths that were put in are actual file paths. We then perform some string manipulation to rename the output files as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.txt&lt;/code&gt; versions of the original file names. Finally, in the main for-loop, we construct a command line command as a string for each bed file we want to annotate. This line is the most important.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;command += f&quot;--export=INPUT={bed},OUTPUT={out},GTFDB={gtfdb} &quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;INPUT&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OUTPUT&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GTFDB&lt;/code&gt; are the same variables we specfied in our &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;template.sh&lt;/code&gt; script. The final string gets passed to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;os.system()&lt;/code&gt; which runs the command as if you were typing it out in the terminal. An example command might look something like this&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sbatch -A mjlab -o ./logs --export=INPUT=./bedfiles,OUTPUT=./out,GTFDB=hg41.gtf.db template.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here is an example of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;submit.sh&lt;/code&gt; file&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ROOT=&quot;/burg/mjlab/users/ew2579/&quot;

python submit_jobs.py \
	--input &quot;$ROOT/spidr/encode_data/downsampled_peaks_filtered&quot; \
	--output &quot;$ROOT/darvesh_annotator/output/encode/downsampled_peaks_filtered&quot; \
	--logs &quot;$ROOT/darvesh_annotator/logs/encode/downsampled_peaks_filtered&quot; \
	--gtfdb &quot;$ROOT/spidr/reference_files/gencode.v41.annotation.gtf.db&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ROOT&lt;/code&gt; is specified at the top to save some typing. The final command to run this would be the following:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bash submit.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;outcome&quot;&gt;Outcome&lt;/h3&gt;
&lt;p&gt;This would run the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python&lt;/code&gt; command with the proper arguments for all the directory paths. The python program in turn creates various batch jobs by parsing each file in the directory. The various batch jobs are independent of one another so they’re all running separately. The result is that what would’ve taken 12-16 hours now only takes 30 to 45 minutes to run.&lt;/p&gt;

&lt;hr /&gt;
&lt;h1 id=&quot;building-custom-singularity-containers&quot;&gt;Building Custom Singularity Containers&lt;/h1&gt;
&lt;p&gt;Containers are like miniature computers inside your computer that can package your application in a very isolated way. Ginsburg like most HPCs does not allow users to build or run Docker containers which is the most popular containerization software. This is mainly because Docker requires root privileges on the computer which is risky on a shared resource like an HPC.&lt;/p&gt;

&lt;h3 id=&quot;step-1-1&quot;&gt;Step 1.&lt;/h3&gt;
&lt;p&gt;First we want to create a singularity container to contain all the dependencies of our project since it uses both R and Python. In our case, there is an existing Docker container which can do this. We want to build the container on our local machine. Go to the directory with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Dockerfile&lt;/code&gt; and run&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; docker build . -t &amp;lt;tag name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;tag name&amp;gt;&lt;/code&gt; is whatever tag you want to use to easily identify your container.&lt;/p&gt;

&lt;h3 id=&quot;step-2-1&quot;&gt;Step 2.&lt;/h3&gt;
&lt;p&gt;Save the image as a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tar&lt;/code&gt; file.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker save &amp;lt;tag name&amp;gt; -o &amp;lt;filename&amp;gt;.tar
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;tag name&amp;gt;&lt;/code&gt; is the same &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;tag name&amp;gt;&lt;/code&gt; from &lt;a href=&quot;#step-2-1&quot;&gt;Step 2&lt;/a&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;filename&lt;/code&gt; is whatever you want your output file to be called. If I used &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;darveshgorhe/secat-dev&lt;/code&gt; as my tag name and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;secat&lt;/code&gt; as my filename I would run&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker save darveshgorhe/secat-dev -o secat.tar
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;step-3-1&quot;&gt;Step 3.&lt;/h3&gt;
&lt;p&gt;Upload the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tar&lt;/code&gt; file to Ginsburg using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scp&lt;/code&gt;. You can also use the Globus tool to upload the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tar&lt;/code&gt; file wherever you want.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;scp &amp;lt;filename&amp;gt;.tar '&amp;lt;UNI&amp;gt;@ginsburg.rcs.columbia.edu:&amp;lt;path to store tar file&amp;gt;'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;step-4-1&quot;&gt;Step 4.&lt;/h3&gt;
&lt;p&gt;On Ginsburg, build your container from the tar file as a sandbox container&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;singularity build --sandbox &amp;lt;sandbox name&amp;gt; docker-archive://&amp;lt;filename&amp;gt;.tar
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;
&lt;h1 id=&quot;developing-a-python-package-on-ginsburg&quot;&gt;Developing a Python Package on Ginsburg&lt;/h1&gt;
&lt;p&gt;I’ve recently been trying to improve a package called &lt;a href=&quot;https://github.com/grosenberger/secat&quot;&gt;SECAT&lt;/a&gt; for analyzing SEC-SWATH mass Spectrometry data. The package requires a lot of memory and compute to run in a reasonable amount of time. Specifically, it requires more memory than I have available on my computer and it heavily utilizes multiprocessing to parallelize parts of the code. What might take hours on my laptop can be done in less than 20 minutes on the computer. Since I’m editing the code very often, running it on my local computer is impractical. How can we use Ginsburg to solve this problem?&lt;/p&gt;

&lt;h3 id=&quot;step-1-2&quot;&gt;Step 1.&lt;/h3&gt;
&lt;p&gt;Make sure you have a singularity sandbox container with all the proper dependencies. If you’re not sure how to make one, look at the &lt;a href=&quot;#building-custom-singularity-containers&quot;&gt;previous section&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;step-2-2&quot;&gt;Step 2.&lt;/h3&gt;
&lt;p&gt;First clone what ever repository you want with&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone &amp;lt;git repository link&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;By default this copies the contents of the repository into a folder in your current working directory with the same name as the repository. So if I was in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/home/&lt;/code&gt; and I ran &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git@github.com:grosenberger/secat.git&lt;/code&gt; it would create a folder called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;secat&lt;/code&gt; in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/home/&lt;/code&gt; and the contents of the repository would be in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/home/secat&lt;/code&gt;. If you want to copy it somewhere else, run&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone &amp;lt;git repository link&amp;gt; &amp;lt;desired folder&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Where &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;desired folder&amp;gt;&lt;/code&gt; is where you want the contents of the repository to be copied to. Once this is done, navigate to the repository you downloaded. In the case of the example you could do &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cd /home/secat&lt;/code&gt; to enter into the repository folder. We’re going to install the python package in editatable mode. Editable mode tells your Python interpreter to look at the folder you specified rather than the default location of your packages.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pip install --editable .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.&lt;/code&gt; tells &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pip&lt;/code&gt; to look in the current folder for the python package, specifically the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setup.py&lt;/code&gt; file. If this runs successfully, you should see a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.egg-info&lt;/code&gt; file generated. This is what tells &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pip&lt;/code&gt; to look in the current folder rather than where it normally looks for packages.&lt;/p&gt;

&lt;p&gt;Ideally you want to do this in the same directory as your sandbox so the file tree might look something like this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sandbox
├── bin -&amp;gt; usr/bin
├── boot
├── dev
├── ...
python_package
├── Dockerfile
├── LICENSE
├── README.md
├── ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;step-3-2&quot;&gt;Step 3.&lt;/h3&gt;
&lt;p&gt;Check that the sandbox + editable python package works properly. In my case I would edit some of the help documentation and then type in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;singularity exec sandbox secat --help&lt;/code&gt; to ensure that everything was installed properly. If it works you should see your changes reflected in the output of your command. Just running the program could also be a good way to check, but make sure your edits are reflected in the program’s execution. Deleting an import and checking if it works is another quick way to check.&lt;/p&gt;

&lt;h1 id=&quot;glossary&quot;&gt;Glossary&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;Host Machine&lt;/em&gt;: The machine you’re logging into Ginsburg from. This is probably a laptop or desktop computer. You could also login via another server, but this is usually unlikely.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Remote Machine&lt;/em&gt;: This is Ginsburg in our case. But generally, it’s a computer that you want to access from a distance over a network (not necessarily the internet).&lt;/p&gt;</content><author><name></name></author><category term="educational" /><summary type="html">Introduction Ginsburg is the name of Columbia University’s newest high performance computing cluster (HPC). As a Data Science Master’s student at the university I’ve been using Ginsburg for my work in the Jovanovic Lab. There’s plenty of very basic stuff in Ginsburg’s documentation. I want to cover some more involved things which could improve your quality of life while using or developing code, dramatically decrease the amount of time it takes to run code, or make some things feasible which were previously infeasible.</summary></entry><entry><title type="html">Redefining-Education: How Can We Change the Meta-constraints?</title><link href="https://dgorhe.github.io/blog/education/2022/08/24/Redefining-Education.html" rel="alternate" type="text/html" title="Redefining-Education: How Can We Change the Meta-constraints?" /><published>2022-08-24T20:00:00+00:00</published><updated>2022-08-24T20:00:00+00:00</updated><id>https://dgorhe.github.io/blog/education/2022/08/24/Redefining-Education</id><content type="html" xml:base="https://dgorhe.github.io/blog/education/2022/08/24/Redefining-Education.html">&lt;h2 id=&quot;scope&quot;&gt;Scope&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;K-12 education&lt;/li&gt;
  &lt;li&gt;No higher education&lt;/li&gt;
  &lt;li&gt;Should apply to all grades but…&lt;/li&gt;
  &lt;li&gt;Some advice is more applicable/specific to high school&lt;/li&gt;
  &lt;li&gt;Going to explain ideas at multiple levels of depth&lt;/li&gt;
  &lt;li&gt;Each level of depth discusses further n-th order effects and more subtle considerations&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;list-of-ideas&quot;&gt;List of ideas&lt;/h2&gt;
&lt;p&gt;The 5 ideas I propose are as follows:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Teachers as advisors versus lecturers&lt;/li&gt;
  &lt;li&gt;Setting clear numeracy goals&lt;/li&gt;
  &lt;li&gt;Fixed-value per student voucher system&lt;/li&gt;
  &lt;li&gt;Testing as a means of progression&lt;/li&gt;
  &lt;li&gt;Mandatory rotational programs for students&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;surface-level-explanation&quot;&gt;Surface Level Explanation&lt;/h2&gt;
&lt;h3 id=&quot;teachers-as-advisors-versus-lecturers&quot;&gt;Teachers as advisors versus lecturers&lt;/h3&gt;
&lt;p&gt;PhDs are valued because much of the work by the candidate is done asynchronously and independently. The internet is also filled with high quality instruction/lectures on a wide variety of topics. A teacher shouldn’t be repeating the same material over and over to different students, we have the internet for that. Instead, teachers should be advisors to students in order to spend high-quality time with them even if that time is less in quantity per child.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Need to run the math on how this plan would affect number of teachers&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;setting-clear-numeracy-goals&quot;&gt;Setting clear numeracy goals&lt;/h3&gt;
&lt;p&gt;We have a clear language for describing literacy among children. We can discretize students’ reading ability by grade level. It’s not a perfect system, but at least it’s directionally helpful. A particular student at a 3rd grade reading level may know more than a particular student at a 4th grade reading level. However, a student at a 12th grade reading level can almost assuredly read better than a student at a 4th grade reading level. We should create a similar metric for math called numeracy. Basically, at what is a child’s aptitude to manipulate and transform numerical concepts?&lt;/p&gt;

&lt;h3 id=&quot;fixed-value-per-student-voucher-system&quot;&gt;Fixed-value per student voucher system&lt;/h3&gt;
&lt;p&gt;Each school gets some fixed amount per student they enroll. They are free to charge anything above that amount. But there’s a minimum guaranteed amount regardless of property tax and year-to-year fluctuations.&lt;/p&gt;

&lt;h3 id=&quot;testing-as-a-means-of-progression&quot;&gt;Testing as a means of progression&lt;/h3&gt;
&lt;p&gt;Every student should always be able to test out of any course at any time. The earlier they test out relative to their age, the stricter the cutoff (i.e. higher percentage needed to pass). They can get multiple attempts, but fixed number per time window. If there are expected ages for the courses, the student will have to re-test in order to not remediate back to that class. In other words, the student has to demonstrate that they retained the knowledge for the course they tested out of early.&lt;/p&gt;

&lt;h3 id=&quot;mandatory-rotational-programs-for-students&quot;&gt;Mandatory rotational programs for students&lt;/h3&gt;
&lt;p&gt;This primarily applies to high schools. Before graduating, I believe half the time should be spent rotating through various types of positions. This connects with the voucher system since this can be used to incentivize employers to take on students through rotation programs. Students and parents may sign a release form for some physical labor, but there would need to exist some state-level restrictions since this could become a perverse incentive for cheap labor for hazardous work.&lt;/p&gt;

&lt;hr /&gt;
&lt;h2 id=&quot;slightly-deeper-explanation&quot;&gt;Slightly Deeper Explanation&lt;/h2&gt;
&lt;h3 id=&quot;teachers-as-advisors-versus-lecturers-1&quot;&gt;Teachers as advisors versus lecturers&lt;/h3&gt;
&lt;h3 id=&quot;setting-clear-numeracy-goals-1&quot;&gt;Setting clear numeracy goals&lt;/h3&gt;
&lt;h3 id=&quot;fixed-value-per-student-voucher-system-1&quot;&gt;Fixed-value per student voucher system&lt;/h3&gt;
&lt;h3 id=&quot;testing-as-a-means-of-progression-1&quot;&gt;Testing as a means of progression&lt;/h3&gt;
&lt;h3 id=&quot;mandatory-rotational-programs-for-students-1&quot;&gt;Mandatory rotational programs for students&lt;/h3&gt;

&lt;hr /&gt;
&lt;h2 id=&quot;deep-explanation&quot;&gt;Deep Explanation&lt;/h2&gt;
&lt;h3 id=&quot;teachers-as-advisors-versus-lecturers-2&quot;&gt;Teachers as advisors versus lecturers&lt;/h3&gt;
&lt;h3 id=&quot;setting-clear-numeracy-goals-2&quot;&gt;Setting clear numeracy goals&lt;/h3&gt;
&lt;h3 id=&quot;fixed-value-per-student-voucher-system-2&quot;&gt;Fixed-value per student voucher system&lt;/h3&gt;
&lt;h3 id=&quot;testing-as-a-means-of-progression-2&quot;&gt;Testing as a means of progression&lt;/h3&gt;
&lt;h3 id=&quot;mandatory-rotational-programs-for-students-2&quot;&gt;Mandatory rotational programs for students&lt;/h3&gt;</content><author><name></name></author><category term="education" /><summary type="html">Scope K-12 education No higher education Should apply to all grades but… Some advice is more applicable/specific to high school Going to explain ideas at multiple levels of depth Each level of depth discusses further n-th order effects and more subtle considerations</summary></entry><entry><title type="html">Beyond Bitcoin: How to Implement Decentralized Societies</title><link href="https://dgorhe.github.io/blog/decentralization/2022/01/07/Beyond-Bitcoin.html" rel="alternate" type="text/html" title="Beyond Bitcoin: How to Implement Decentralized Societies" /><published>2022-01-07T17:10:00+00:00</published><updated>2022-01-07T17:10:00+00:00</updated><id>https://dgorhe.github.io/blog/decentralization/2022/01/07/Beyond-Bitcoin</id><content type="html" xml:base="https://dgorhe.github.io/blog/decentralization/2022/01/07/Beyond-Bitcoin.html">&lt;h2 id=&quot;preamble&quot;&gt;Preamble&lt;/h2&gt;
&lt;p&gt;I’m writing this out of self-interest as well as a desire to push technological progressivism. As &lt;a href=&quot;https://balajis.com/the-purpose-of-technology/&quot;&gt;Balaji Srinivasan put it in 2013&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;We need to consciously build a parallel tech-driven decentralized media ecosystem, and we need it to become the first point of call for anyone seeking to learn about technology.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;While I disagree with some of Balaji’s &lt;a href=&quot;https://www.wired.com/2013/11/software-is-reorganizing-the-world-and-cloud-formations-could-lead-to-physical-nations/&quot;&gt;opinions on the physical manifestations of social networks&lt;/a&gt;, it’s obvious that software is subsuming peoples’ time and attention. Balaji has a particular idea that I want to focus on, that of &lt;a href=&quot;https://1729.com/how-to-start-a-new-country&quot;&gt;starting a new non-contiguous country&lt;/a&gt;. He leaves the implementation details to the readers’ imagination so in this post we’ll expound upon this idea with a concrete implementation. To the chagrin of many tech evangelists, we cannot wholly extricate our physical existence to the cloud no matter how cheap the EC2 instances become. Nonetheless, we can exercise agency in how and where technology will take our time, resources, and agency.&lt;/p&gt;

&lt;p&gt;Specifically we’re going to examine how to keep record of the physical citizens of &lt;em&gt;any&lt;/em&gt; polity, digital or physical. There are a plethora of fascinating topics to discuss for decentralized societies such as food supply, delineation of trade routes, addressing natural disasters, etc. I’m choosing this topic because it’s by definition the entry point of every human into any society. Those other topics may be the focus of future blog posts.&lt;/p&gt;

&lt;h2 id=&quot;background---conceptualizing-daos&quot;&gt;Background - Conceptualizing DAOs&lt;/h2&gt;
&lt;blockquote&gt;
  &lt;p&gt;A blockchain is a growing list of records, called blocks, that are linked together using cryptography.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;A decentralized autonomous organization (DAO)… is an organization represented by rules encoded as a computer program that is transparent, controlled by the organization members and not influenced by a central government.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The title mentions the term DAO, but let’s relate DAOs to existing terminology to form a better intuition. We can view DAOs as an anarchic polity or a direct democracy. DAOs can be considered anarchic because there is no centralized control and no individual actually has to participate in any DAO - the null is zero participation. However, whenever people do partcipate everyone, by design, has an equal say at the start. As such it can be viewed as a direct democracy. A more colloquial example to conceptualize DAOs would be any sort of online group that exerts some authority. A recent example would be influence of the &lt;a href=&quot;https://reddit.com/r/wallstreetbets&quot;&gt;WallStreetBets subreddit&lt;/a&gt; on the price of GameStop stock in 2021. They were a loosely organized coalition that had some rules, albeit not transparent, encoded in the subreddit. Ultimately, the users decided how they wanted to exercise their stock trades and call options for GameStop, but the group itself had some concerted, measureable effect on the market. These analogies will always be inexact, but the point is to help triangulate the term DAO within our existing lexicon.&lt;/p&gt;

&lt;h2 id=&quot;thesis&quot;&gt;Thesis&lt;/h2&gt;
&lt;p&gt;Ok so I’ve been rambling about &lt;em&gt;why&lt;/em&gt; I’m writing this but &lt;em&gt;what&lt;/em&gt; is this about? It’s simply this idea:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;What if we had a system of governance where each birth and death was put on a blockchain and people could join DAOs of various scales based on the institutions in which they want to have a say?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;why-should-we-care&quot;&gt;Why Should We Care?&lt;/h2&gt;
&lt;p&gt;We should care about this because many aspects of society require identification and there is often too much friction in the existing centralized infrastructure. Certain data should be anonymized wherever we deem necessary, but we shouldn’t throw the baby out with the bath water. Complete anonymity of every citizen would make society untenable. Driving on roads, flying on a plane, starting a business all require us to prove that we are who we say we are - and that should continue to be the case. Government identification works fine, but there are flaws. A core issue is that governments want to create identification that is physically mass producible but difficult to forge. The more complicated and expensive your passport becomes, the less accessible it becomes to the populous (subsidized or not). We would like to have an opt-in system that addresses this core issue such that citizens would feel compelled to opt-in to the new system or at worst, both the old and new system. This is where blockchains come into the picture.&lt;/p&gt;

&lt;p&gt;Let’s say you’re a new parent and your home town has a blockchain of birth records. Your child’s birth would be stored on there, immutably. You don’t have to worry if the hospital closes or you lose the birth certificate, the record of your child always exists. This birth record would enable you as parents to automatically be given access to votes related to child safety, education, etc. At larger scales, your vote gets correspondingly diluted, but the consequences of your votes become more impactful. To extend the education analogy, parents might have a more diluted influence in the education policy of North America but the scope of influence would be beyond that of the home town DAO.&lt;/p&gt;

&lt;p&gt;We could even extend this to global governance. Imagine if we could vote on climate change issues globally? Stupidity is high-entropy when things are left to an open choice. “What should we do about climate change?” is different than, “Should we do X or Y about climate change?”. In the former, people proactively propose solutions whereas the latter is a false choice often promulgated by governments. Imagine policy debates that reinforce the minimization of posturing. Citizens could waste time posturing to appear to do something, or reach out to other factions and reach a consensus. A DAO based system would incentivize the latter but not necessarily prevent the former. Factions that are apathetic about climate change &lt;em&gt;would have to actively organize to convince other voters to abstain from voting&lt;/em&gt;. Similarly, DAO members could spend their time convincing members to leave to increase the voting power of a single vote, but that costs time and energy. These are all downstream effects of things built on top of this birth record system, but could we actually put &lt;em&gt;all&lt;/em&gt; births on a blockchain? There’s a lot of babies born so this is a non-trivial question.&lt;/p&gt;

&lt;h2 id=&quot;feasibility-in-a-proof-of-work-system&quot;&gt;Feasibility in a Proof-of-Work System&lt;/h2&gt;
&lt;p&gt;Let’s talk about the technicalities of this. How can we determine if all births can be put on a blockchain? How do we get from birth records to DAOs and global governance?&lt;/p&gt;

&lt;h3 id=&quot;block-design&quot;&gt;Block Design&lt;/h3&gt;
&lt;p&gt;Around &lt;a href=&quot;https://www.theworldcounts.com/stories/How-Many-Babies-Are-Born-Each-Day&quot;&gt;385,000 babies are born per day&lt;/a&gt;. If we assume there rate is constant this means approximately 2,674 babies are born every 10 minutes. I’m using 10 minutes because by default that’s how often a block is written for &lt;a href=&quot;https://github.com/bitcoin/bitcoin&quot;&gt;bitcoin&lt;/a&gt;. Each block has a theoretical &lt;a href=&quot;https://github.com/bitcoin/bitcoin&quot;&gt;4mb limit&lt;/a&gt;. Let’s imagine the following very basic example mocked up in TypeScript.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;
  &lt;pre&gt;&lt;code class=&quot;language-typescript&quot; data-lang=&quot;typescript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;block&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;uuid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;parents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;uuid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[];&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;custody&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;LinkedList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;uuid&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;lat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BigInt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;lon&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BigInt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/figure&gt;

&lt;p&gt;We’ll discuss optional parameters in the following section.&lt;/p&gt;

&lt;h3 id=&quot;block-size&quot;&gt;Block Size&lt;/h3&gt;
&lt;p&gt;Typically, a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;uuid&lt;/code&gt; is represented by 32 hexadecimal characters and 4 hyphens. Let’s assume 4 bits per character so 144 bits total so far. For &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;name&lt;/code&gt;, let’s be liberal and use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;UTF-32&lt;/code&gt; which has a fixed length and takes 32 bits per character (how else are we going to store Elon’s son’s name, X Æ A-Xii). We’ll arbitrarily limit names to 50 characters so 1600 bits. It’s important to differentiate custody and parenthood since they can often be decoupled. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;parents&lt;/code&gt; only includes biological parents (2 uuids so 288 bits). With &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;custody&lt;/code&gt; we have an issue. We want to accomodate as many entries as necessary but we can’t accomodate an infinite number of custody changes. Putting an upper bound might be harmful to children if the terminal custodian is abusive or absent. We could use foster care data to determine the maximum number of custodial changes or the 99.9th percentile of custodial changes. For now, we’ll arbitrarily limit this to 18 custodians which I base on having 2 new custodians every 2 years until the child is 18 years old. This amounts to 18 uuids so 2,592 bits. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;BigInt&lt;/code&gt; can store up to 64 bits so &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lat&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lon&lt;/code&gt; together take up 128 bits. All together we have 144 + 288 + 2,592 + 1600 + 128 = 4,752 bits. This is the equivalent of 594 bytes. 594 bytes times 2,674 = 1,588,356 bytes = 1.588 mb. Okay, so we know there is no fundamental limitation to this approach even using something as intensive as proof-of-work as the basis for our blockchain.&lt;/p&gt;

&lt;p&gt;We could add more required or optional items to each block since we have headroom. We might want more attributes so it’s easier for a person to rediscover their id. Specifically with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;id&lt;/code&gt; attribute, I believe the most sustainable way would be to create a hash based on the most variable parts of human DNA in addition to a corneal scan or fingerprint (to account for identical twins). A newborn’s data would be collected, the hash is generated and if someone needs to rediscover their block, they can resequence their DNA and take a new corneal scan or fingerprint scan. Other redundant biological hashes would need to be developed for people with birth defects.&lt;/p&gt;

&lt;p&gt;As long as there is no consistent backlog of births, spikes in birth rate are fine (we just postpone writing them to a block for a few block durations). A proof-of-stake model could be even more amenable to this task although I’m less familiar with the inner workings of proof-of-stake systems.&lt;/p&gt;

&lt;h3 id=&quot;caveats&quot;&gt;Caveats&lt;/h3&gt;
&lt;p&gt;I mentioned the custody caveat and biological hash, but there are some other caveats to keep in mind. Namely, we assumed birth rates are consistent and will remain consistent. We have a ton of headroom so I don’t see this as a real issue. If anything the size of the block should increase to enable more features. If we wanted a more accurate determination, we could look at a histogram of births every 10 minutes across a wide variety of hospitals and areas. From this we could simply use the sum of largest values plus some buffer or some other liberal estimate. I wasn’t able to find a dataset this granular, but if someone knows of such a dataset, please let me know. Hard forks would be another issue since it’s quite likely people will want to change the design of blockchains as time goes on. We could also imagine some fields I listed being empty and thus optional. What if you don’t know who the parents are? We could amend biological hashes such that your hash will always equal the hash of your parents and thus we could reconstruct a family tree. The ethical issues of that decision should be left to individual DAOs. Competing hash functions would likely arise based on peoples’ privacy tolerance. There is also the issue that a child’s inclusion in at least 1 DAO is entirely decided by their parents or initial custodians. I could go on and on, but I don’t think any of these issues are a dealbreaker. The nature of a DAO based system would offer competing solutions and tradeoffs. DAOs are not a panacea.&lt;/p&gt;

&lt;h2 id=&quot;transitioning-to-dao-based-society&quot;&gt;Transitioning to DAO Based Society&lt;/h2&gt;
&lt;p&gt;Beyond the technical challenges facing DAO creation, there is an obvious social component to this transition. What is non-technical core product value of these systems for new users? What incentive is there for an existing person to onboard to this new system? There are advantageous side-effects of creating a biological hash for older citizens. It’s a good way to collect data for personalized medicine. Older people have more complicated ailments and subsidizing genome sequencing could help bolster a database (blockchain or otherwise) of genomes to better research and address these ailments. Moreover, when people die this would be an immutable record of their identity which loved ones could use to resolve legal disputes. Families with children on the way could opt-in to the system knowing that their parenthood and custody is being recorded immutably. Other authentication technologies would be built on top of this system which might end up displacing passports and identification cards for people of all ages. The case to opt-in is weakest for young adults with no families. The most important demographics to focus on would be new parents and immigrants (at least for legal immigration). The best case scenario is that we onboard a majority of new parents within 1 generation. Realistically we would not expect Facebook or Twitter levels of growth, nor should that be the goal. However, we should imbibe the platform lessons from Facebook and Twitter - deliver core product value and everything else will fall into place.&lt;/p&gt;

&lt;h2 id=&quot;consequences&quot;&gt;Consequences&lt;/h2&gt;
&lt;h3 id=&quot;immutable-store-of-people&quot;&gt;Immutable Store of People&lt;/h3&gt;
&lt;p&gt;We have all these blocks, so what? Now we have an immutable store of people born. We could similarly create a blockchain for deaths based on death certificates. The difference between the set of birth ids and the set of ids in the death blockchain is the number of people alive. This forms the basis of token dissemination for the aforementioned organizations. A town could decide that anyone born at a certain group of hospitals is automatically added to the town’s DAO. Citizenship would be optional but it could remain exactly as it is now. Being a part of a nation-state is a choice not a prerequisite. You could avoid joining any DAO but that would be a choice you have to make.&lt;/p&gt;

&lt;h3 id=&quot;built-in-redundancy&quot;&gt;Built-in Redundancy&lt;/h3&gt;
&lt;p&gt;Blockchains are relatively safe from fraud by design. Similarly, natural disasters pose less risk to blockchains since they are distributed. Municipalities could also have redundant chains on the cloud to provide additional security. The cost of fabricating a block for a DAO would be too demanding, even for a cloud provider.&lt;/p&gt;

&lt;h3 id=&quot;built-in-diversity-equity-and-inclusion&quot;&gt;Built-in Diversity, Equity, and Inclusion&lt;/h3&gt;
&lt;p&gt;There is no information about one’s race, sex, gender, etc. in the block. If your id exists and you are not dead, your vote counts. To be fair, a real issue would be if people are denied a birth block on the basis of these characteristics. What if Uighurs in China are denied person-hood from birth on the basis of their family’s religion? Then again, keeping track of people in a separate database uses a lot of time and energy. At that point people have to wonder, what’s in it for me? Unlike a lot of bitcoin maximalists and decentralization diehards, I do not think blockchains are the solution to these fundamental moral quandries. It’s totally possible for a totalitarian state to suppress DAOs permanently. DAOs are simply organizations with different trade-offs, ones that I think are more amenable to a highly automated society but prone to human folly just like everything else.&lt;/p&gt;

&lt;h2 id=&quot;voting&quot;&gt;Voting&lt;/h2&gt;
&lt;p&gt;Leaving a DAO would increase the voting power of each share but not by much. Similarly, joining a DAO does not significantly dilute each member’s voting power. A one token one vote method could be used but there are also other methods like &lt;a href=&quot;https://vitalik.ca/general/2019/12/07/quadratic.html&quot;&gt;quadratic payments&lt;/a&gt;. Entities could enact whatever voting rules they want but they would have to balance the risks/benefits of losing voters versus gaining voters for their cause. Perhaps smaller DAOs could have deals with larger DAOs to make changes but those changes are contingent upon having a minimum number of voters. Again, this &lt;em&gt;may&lt;/em&gt; be linked to geography but it does not &lt;em&gt;have to&lt;/em&gt; be linked to geography.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Decentralization is more than just bitcoin. Aren’t you so sick of hearing the same buzzwords and explanations over and over again? “Bitcoin is like digital gold”, “It’s a ledger that governments can’t control” and on and on. We should demand some tangible core product value from blockchains beyond new toys for financial arbitrage. We should be asking for things like cryptocurrency based payroll so we can get paid on a daily or even hourly basis. We should ask for logistics to be a series of smart contracts where changes in warehouse capacity automatically triggers a change in purchase orders. For every dotcom era company we remember today there were dozens that were total nonsense and rightfully called out for being so. Bitcoin might Java Applets and JavaScript might be right under our noses.&lt;/p&gt;

&lt;h2 id=&quot;addendum&quot;&gt;Addendum&lt;/h2&gt;
&lt;p&gt;I want to address probably the best set of criticisms against crypto-adjacent topics. There was a video by Folding Ideas titled Line Goes Up - The Problem With NFTs where he lambasts the idea of crypto currency. He cites the speculative nature of crypto as a continuation of the post 2008 financial crisis and the case is very compelling. Relevant to this posts, he unequivocally rejects the idea of crypto token based governance.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“… while the claim is that these machines will democratize the internet, the technical complexity they add, the new speciailized programming expertise that they require, concentrates a lot of power in the hands of people who can build the templates that in turn enable non-programmers to actually use it.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What I’m proposing here is different because I don’t think I’m proposing a template for DAOs themselves. I’m suggesting that digitizing identities in a robust, seamless way will allow variegated DAOs to emerge. Identification is also a very well understood interface between the analog and digital world so I think average people could wrap their heads around this aspect in particular. Perhaps I’m buying into the decadent ideas put forth by cryto-evangelists but I don’t think I am. Please correct me if I’m wrong. I don’t want to get too far into this criticism, but I can dive deeper if anyone wants.&lt;/p&gt;

&lt;!-- Balaji --&gt;</content><author><name></name></author><category term="decentralization" /><summary type="html">Preamble I’m writing this out of self-interest as well as a desire to push technological progressivism. As Balaji Srinivasan put it in 2013:</summary></entry></feed>