https://github.com/beacon-biosignals/transformspecifications.jl

Structured processing elements with I/O specifications

https://github.com/beacon-biosignals/transformspecifications.jl

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.2%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Structured processing elements with I/O specifications

Basic Info
  • Host: GitHub
  • Owner: beacon-biosignals
  • License: mit
  • Language: Julia
  • Default Branch: main
  • Homepage:
  • Size: 338 KB
Statistics
  • Stars: 0
  • Watchers: 21
  • Forks: 0
  • Open Issues: 6
  • Releases: 0
Created almost 3 years ago · Last pushed over 1 year ago
Metadata Files
Readme License

README.md

TransformSpecifications.jl

docs docs CI codecov

TransformSpecifications.jl provides tools to define explicitly-specified transformation components. Such components can then be used to construct pipelines and DAGs that are themselves composed of individual explicitly-specified components. Additionally, they can be easily wrapped to catch and nicely handle both expected and unexpected specification and transformation violations.

Basic transform example

A basic TransformSpecification is constructed from the input and output specifications and the transformation function to be applied:

```julia julia> using TransformSpecifications julia> ts = TransformSpecification(String, Integer, length)

Valid input

julia> transform!(ts, "greetings") 9

Invalid input

julia> transform!(ts, 92) ERROR: ArgumentError: Input doesn't conform to specification String ```

A NoThrowTransform facilitates the case where a transformation must be robust to unexpected errors---instead of throwing an error, it returns the violation in a NoThrowResult:

```julia julia> ntt = NoThrowTransform(String, Integer, length)

Valid input:

julia> transform!(ntt, "greetings") NoThrowResult{Int64}: Transform succeeded ✅ result: 9

Invalid input:

julia> transform!(ntt, 92) NoThrowResult{Missing}: Transform failed ❌ Input doesn't conform to specification String. Details: MethodError(convert, (String, 92), 0x0000000000007f48)

Invalid output (from the transform function) also throws:

julia> ts = NoThrowTransform(String, String, length) julia> transform!(ts, "foo") NoThrowResult{Missing}: Transform failed ❌ Output doesn't conform to specification NoThrowResult{String}; is instead a NoThrowResult{Int64} ```

NoThrowDAG example

A NoThrowDAG facilitates composing multiple specified transforms (DAGSteps) into a DAG, such that any errors errors encountered during the application of the DAG will be returned "nicely" (i.e., as a NoThrowResult object with the source of failure noted in the violations field) rather than thrown as an exception:

```julia julia> using Legolas: @schema, @version

julia> @schema "one-var" Huzzah julia> @version HuzzahV1 begin var::String end

julia> @schema "two-var" Hooray julia> @version HoorayV1 begin var1::String var2::String end

Say we have three functions we want to chain together:

julia> fna(x::HuzzahV1) = HuzzahV1(; var=x.var * "a") julia> fnb(x::HuzzahV1) = HuzzahV1(; var=x.var * "b") julia> fnc(x::HoorayV1) = HuzzahV1(; var=x.var1 * x.var2 * "c")

First, specify these functions as transforms: what is the specification of the

function's input and output?

julia> stepatransform = NoThrowTransform(HuzzahV1, HuzzahV1, fna) julia> stepbtransform = NoThrowTransform(HuzzahV1, HuzzahV1, fnb) julia> stepctransform = NoThrowTransform(HoorayV1, HuzzahV1, fn_c)

Next, set up the DAG between the upstream outputs into each step's input:

julia> stepbassembler = inputassembler(upstream -> (; var=upstream["step_a"][:var])) julia> stepcassembler = inputassembler(upstream -> (; var1=upstream["step_a"][:var], var2=upstream["step_b"][:var]))

julia> steps = [DAGStep("stepa", nothing, stepatransform), DAGStep("stepb", stepbassembler, stepbtransform), DAGStep("stepc", stepcassembler, stepc_transform)] julia> dag = NoThrowDAG(steps)

output

NoThrowDAG (HuzzahV1 => HuzzahV1): 🌱 stepa: HuzzahV1 => HuzzahV1: `fna · step_b: HuzzahV1 => HuzzahV1:fnb` 🌷 stepc: HoorayV1 => HuzzahV1: fn_c

Call DAG on valid input:

julia> transform!(dag, HuzzahV1(; var="initial_str"))

output

NoThrowResult{HuzzahV1}: Transform succeeded ✅ result: HuzzahV1: (var = "initialstrainitialstrabc",)

Call DAG on invalid input:

transform!(dag, HoorayV1(; var1="wrong", var2="input schema"))

output

NoThrowResult{Missing}: Transform failed ❌ Input to step step_a doesn't conform to specification HuzzahV1. Details: ArgumentError("Invalid value set for field var, expected String, got a value of type Missing (missing)") ```

Finally, a diagram for the DAG can be generated as a mermaid plot: julia mermaidify(dag) which renders automatically when included in a mermaid markdown block in GitHub: ```mermaid flowchart

%% Define steps (nodes) subgraph OUTERLEVEL[""] direction LR subgraph STEPA[Step a] direction TB subgraph STEPAInputSchema[Input: HuzzahV1] direction RL STEPAInputSchemavar{{"var::String"}} class STEPAInputSchemavar classSpecField end subgraph STEPAOutputSchema[Output: HuzzahV1] direction RL STEPAOutputSchemavar{{"var::String"}} class STEPAOutputSchemavar classSpecField end STEPAInputSchema:::classSpec -- fna --> STEPAOutputSchema:::classSpec end subgraph STEPB[Step b] direction TB subgraph STEPBInputSchema[Input: HuzzahV1] direction RL STEPBInputSchemavar{{"var::String"}} class STEPBInputSchemavar classSpecField end subgraph STEPBOutputSchema[Output: HuzzahV1] direction RL STEPBOutputSchemavar{{"var::String"}} class STEPBOutputSchemavar classSpecField end STEPBInputSchema:::classSpec -- fnb --> STEPBOutputSchema:::classSpec end subgraph STEPC[Step c] direction TB subgraph STEPCInputSchema[Input: HoorayV1] direction RL STEPCInputSchemavar1{{"var1::String"}} class STEPCInputSchemavar1 classSpecField STEPCInputSchemavar2{{"var2::String"}} class STEPCInputSchemavar2 classSpecField end subgraph STEPCOutputSchema[Output: HuzzahV1] direction RL STEPCOutputSchemavar{{"var::String"}} class STEPCOutputSchemavar classSpecField end STEPCInputSchema:::classSpec -- fnc --> STEPCOutputSchema:::classSpec end

%% Link steps (edges) STEPA:::classStep -..-> STEPB:::classStep STEPB:::classStep -..-> STEPC:::classStep

end OUTERLEVEL:::classOuter ~~~ OUTERLEVEL:::classOuter

%% Styling definitions classDef classOuter fill:#cbd7e2,stroke:#000,stroke-width:0px; classDef classStep fill:#eeedff,stroke:#000,stroke-width:2px; classDef classSpec fill:#f8f7ff,stroke:#000,stroke-width:1px; classDef classSpecField fill:#fff,stroke:#000,stroke-width:1px; ```

For more TransformSpecification.jl details and examples, see the documentation!

GitHub Events

Total
  • Pull request event: 1
Last Year
  • Pull request event: 1

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 22
  • Total pull requests: 40
  • Average time to close issues: 5 days
  • Average time to close pull requests: 3 days
  • Total issue authors: 4
  • Total pull request authors: 4
  • Average comments per issue: 1.82
  • Average comments per pull request: 0.78
  • Merged pull requests: 39
  • Bot issues: 0
  • Bot pull requests: 6
Past Year
  • Issues: 0
  • Pull requests: 8
  • Average time to close issues: N/A
  • Average time to close pull requests: 8 days
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 6
Top Authors
Issue Authors
  • ericphanson (5)
  • hannahilea (4)
  • JuliaTagBot (1)
Pull Request Authors
  • hannahilea (12)
  • dependabot[bot] (8)
  • ericphanson (4)
  • palday (2)
Top Labels
Issue Labels
Pull Request Labels
dependencies (8)

Packages

  • Total packages: 1
  • Total downloads:
    • julia 4 total
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
juliahub.com: TransformSpecifications

Structured processing elements with I/O specifications

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 4 Total
Rankings
Dependent repos count: 10.1%
Dependent packages count: 37.1%
Average: 43.8%
Forks count: 53.7%
Stargazers count: 74.4%
Last synced: 10 months ago