Skip to content

Instantly share code, notes, and snippets.

Given these pairs:

patient,referral
p29286416172,r19529956641
p49607832635,r19293807841
p69929249091,r19057659047
p90250665558,r19821510137
p10572084327,r19585361336
p30893500781,r19349212531
p51214917243,r19113063730

Large Payloads testing work overview

There are 5 Pull Requests, which I recommend should be merged in the following order:

  • Genomic Record Referral Search bugfix: PR 813 This is a very small one (~21 lines), but has its own ticket. It blocks the test from passing.
  • Config Test data fix: PR 115
    Extremely tiny (~4 lines) - should only take a minute.
  • Genomic Record Bulk data generation command: PR 815 Contains a large amount of the work (~900 lines), specifically enables us to generate
@jacksmith15
jacksmith15 / func.py
Last active September 23, 2022 15:12
from functools import partial, reduce
import operator
from typing import Callable, Iterable, Union
from funcy import compose, identity
class Function:
"""Function wrapper with composition methods."""
def __init__(self, func: Union[Callable, "Function"]):

Fungebra syntax

Expression syntax for composing and manipulating Python functions.

from fungebra import Function
from external_library import other_func

@Function
def my_func():

Release guide

Developer-oriented guide to named release branching process.

This concerns how delivery teams interact with the release process via a branching strategy rather than the wider release process.

Steps

  1. Release candidate branches may be merged into master once the previous named release completes E2E testing.
    • Mark to own updates on completion of E2E testing.
  • Developers to own:
from typing import List, Union
from statham.dsl.constants import Maybe
from statham.dsl.elements import (
AnyOf,
Array,
Boolean,
Integer,
Null,
Number,
from sys import argv, exit
import csv
def main():
if len(argv) != 3:
print("Usage: python dna.py filename.csv filename.txt")
exit(1)
people = []
@jacksmith15
jacksmith15 / type-annotations.md
Last active September 23, 2022 15:12
Type annotations 101

Type Annotations

Full documentation is here.

Type annotations do not affect runtime, but allow other tools to statically analyse you code for errors. The offical checker is MyPy, which has an IntelliJ extension.

Variable annotations

Type annotations come after the variable/attribute declaration (unlike Java):

foo: int
foo = 1

Some examples of CSV operations in Python

Using standard library

The following uses the csv standard library, specifically DictReader, to parse a CSV as a list of dictionaries.

DictReader accepts the file handler, and automatically parses the header for the field names. It can then be iterated to get each row of the CSV. This happens lazily by default, but since we want the whole thing, we load it into a list (which means we can let the file close.

import csv

EAFP vs LBYL

This illustrates the difference between EAFP (Easier to ask forgiveness than permission) vs LBYL (Look before you leap).

To illustrate, consider a function which gets a value from a dictionary by key, returning a default if not present. This is the function implemented in each style:

Look before you leap:

def get(dictionary, key, default):
 if key in dictionary: