Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inheriting code from decapodes #1

Merged
merged 16 commits into from
Dec 19, 2023
22 changes: 22 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
env:
JULIA_VERSION: "1.9.3"

steps:

- label: ":hammer: Build Project"
command:
- "module load julia"
- "julia --project --color=yes -e 'using Pkg; Pkg.instantiate()'"
- "julia --project=docs/ --color=yes -e 'using Pkg; Pkg.instantiate()'"
- "julia --project=docs/ --color=yes -e 'using Pkg; Pkg.precompile()'"

- wait

- label: ":scroll: Build docs"
command:
- "srun --mem=8G --time=1:00:00 --output=log_%j.log jobscript.sh"
env:
JULIA_PROJECT: "docs/"

- wait

23 changes: 12 additions & 11 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
name = "DiagrammaticEquations.jl"
uuid = "b66562e1-fa90-4e8b-9505-c909188fab76"
name = "DiagrammaticEquations"
uuid = "6f00c28b-6bed-4403-80fa-30e0dc12f317"
license = "MIT"
authors = authors = [
"James Fairbanks",
"Andrew Baas",
"Evan Patterson",
"Luke Morris",
"George Rauta",
]
authors = ["James Fairbanks", "Andrew Baas", "Evan Patterson", "Luke Morris", "George Rauta"]
version = "0.0.1"

[deps]
Catlab = "d3509f1a-f4fe-4f63-b9c2-a8cefdb22603"
AlgebraicRewriting = "725a01d3-f174-5bbd-84e1-b9417bad95d9"
Catlab = "134e5e36-593f-5add-ad60-77f754baafbe"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[compat]
Catlab = "^0.14"
AlgebraicRewriting = "0.2"
Catlab = "0.15"
DataStructures = "0.18.13"
MLStyle = "0.4.17"
julia = "1.6"
88 changes: 9 additions & 79 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,13 @@
# AlgebraicX.jl
# DiagrammaticEquations.jl

[![Stable Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://AlgebraicJulia.github.io/AlgebraicX.jl/stable)
[![Development Documentation](https://img.shields.io/badge/docs-dev-blue.svg)](https://AlgebraicJulia.github.io/AlgebraicX.jl/dev)
[![Code Coverage](https://codecov.io/gh/AlgebraicJulia/AlgebraicX.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/AlgebraicJulia/AlgebraicXe.jl)
[![CI/CD](https://github.com/AlgebraicJulia/AlgebraicX.jl/actions/workflows/julia_ci.yml/badge.svg)](https://github.com/AlgebraicJulia/AlgebraicX.jl/actions/workflows/julia_ci.yml)
[![Stable Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://AlgebraicJulia.github.io/DiagrammaticEquations.jl/stable)
[![Development Documentation](https://img.shields.io/badge/docs-dev-blue.svg)](https://AlgebraicJulia.github.io/DiagrammaticEquations.jl/dev)
[![Code Coverage](https://codecov.io/gh/AlgebraicJulia/DiagrammaticEquations.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/AlgebraicJulia/DiagrammaticEquations.jl)
[![CI/CD](https://github.com/AlgebraicJulia/DiagrammaticEquations.jl/actions/workflows/julia_ci.yml/badge.svg)](https://github.com/AlgebraicJulia/DiagrammaticEquations.jl/actions/workflows/julia_ci.yml)

A template repository for making a new AlgebraicJulia package.
`DiagrammaticEquations.jl` is a Julia library implementing category theory to reason formally about diagrammatic representations of systems of algebraic and differential equations.

## 🛠️ Usage
Currently DiagrammaticEquations.jl contains two submodules, `Deca` and `Learn` for supporting `Decapodes.jl` and `AlgebraicLearning.jl` functionality.

1. Use the "Use this template" dropdown to select "Create a new repository"
2. In the new page select "AlgebraicJulia" as the owner, give the repository a name such as "AlgebraicX.jl", and create a new repository from the template
3. Set up Codecov credentials for code coverage (If you have trouble, reach out to an AlgebraicJulia organization owner to help with this)

1. Log into [Codecov](https://codecov.io) with your GitHub account (this requires that you are a member of the AlgebraicJulia organization)
2. Navigate to the [AlgebraicJulia organization](https://app.codecov.io/gh/AlgebraicJulia)
3. Select your new repository from the list (e.x. "AlgebraicX")
4. Note down the `CODECOV_TOKEN` value (It may be in the "Settings" tab if it doesn't show up immediately)
5. Navigate back to your new GitHub repository and go to the Settings tab
6. Go to "Security", "Secrets and variables", and "Actions" and click the "New repository secret" button
7. Give the secret name `CODECOV_TOKEN` and the Secret value is the value you noted from the Codecov settings
8. Click "Add secret"

4. Clone the new repository, for example in the terminal:
```sh
git clone https://github.com/AlgebraicJulia/AlgebraicX.jl.git
cd AlgebraicX.jl
```
5. Rename the file `src/AlgebraicX.jl` to match the name of your new package (e.x. "AlgebraicX")
```sh
mv src/AlgebraicX.jl src/AlgebraicX.jl
```
6. Replace all instances of the word "AlgebraicX" with your new package name (e.x. "AlgebraicX")
```sh
# On linux
git grep -l 'AlgebraicX' | xargs sed -i 's/AlgebraicX/AlgebraicX/g'
# On Mac OS X
git grep -l 'AlgebraicX' | xargs sed -i '' -e 's/AlgebraicX/AlgebraicX/g'
```
7. Generate a new random version 4 UUID (you can get one here: https://www.uuidgenerator.net/version4)
- We will assume for this example that your new UUID is `<UUID>`
8. Replace all instances of the template's UUID, "b66562e1-fa90-4e8b-9505-c909188fab76", with your new UUID (e.x. "<UUID>")
```sh
# On linux
git grep -l 'b66562e1-fa90-4e8b-9505-c909188fab76' | xargs sed -i 's/b66562e1-fa90-4e8b-9505-c909188fab76/<UUID>/g'
# On Mac OS X
git grep -l 'b66562e1-fa90-4e8b-9505-c909188fab76' | xargs sed -i '' -e 's/b66562e1-fa90-4e8b-9505-c909188fab76/<UUID>/g'
```
9. Commit these new changes to your repository
```sh
git commit -am "Set up skeleton for AlgebraicX.jl"
git push
```
10. Go back to your repository and wait until the tests have passed, you can check the status by going to the "Actions" tab in the repository

### 📔 Set Up GitHub Pages (Public Repos Only)

1. Follow the Usage steps above to set up a new template, make sure all initial GitHub Actions have passed
2. Navigate to the repository settings and go to "Code and automation", "Pages"
3. Make sure the "Source" dropdown is set to "Deploy from a branch"
4. Set the "Branch" dropdown to "gh-pages", make sure the folder is set to "/ (root)", and click "Save"
5. Go back to the main page of your repository and click the gear to the right of the "About" section in the right side column
6. Under "Website" check the checkbox that says "Use your GitHub Pages website" and click "Save changes"
7. You will now see a URL in the "About" section that will link to your package's documentation

### 🛡️ Set Up Branch Protection (Public Repos Only)

1. Follow the Usage steps above to set up a new template, make sure all initial GitHub Actions have passed
2. Navigate to the repository settings and go to "Code and automation", "Branches"
3. Click "Add branch protection rule" to start adding branch protection
4. Under "Branch name pattern" put `main`, this will add protection to the main branch
5. Make sure to set the following options:
- Check the "Require a pull request before merging"
- Check the "Request status checks to pass before merging" and make sure the following status checks are added to the required list:
- CI / Documentation
- CI / Julia 1 - ubuntu-latest - x64 - push
- CI / Julia 1 - ubuntu-latest - x86 - push
- CI / Julia 1 - windows-latest - x64 - push
- CI / Julia 1 - windows-latest - x86 - push
- CI / Julia 1 - macOS-latest - x64 - push
- Check the "Restrict who can push to matching branches" and add `algebraicjuliabot` to the list of people with push access
6. Click "Save changes" to enable the branch protection
## Relevant Work
* Patterson, E., Baas, A., Hosgood, T., & Fairbanks, J. (2022). A diagrammatic view of differential equations in physics. arXiv preprint arXiv:2204.01843.
7 changes: 0 additions & 7 deletions docs/literate/literate_example.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# # Code Example
#
# This is an example of adding a code example compiled with Literate.jl in the docs.
#
# First we want to load our package with `using`

using DiagrammaticEquations

# ## Using `hello()`
#
# We provide the `hello(string)` method which prints "Hello, `string`!"

hello("World")
8 changes: 4 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ if !no_literate
# Set Literate.jl config if not being compiled on recognized service.
config = Dict{String,String}()
if !(haskey(ENV, "GITHUB_ACTIONS") || haskey(ENV, "GITLAB_CI"))
config["nbviewer_root_url"] = "https://nbviewer.jupyter.org/github/AlgebraicJulia/AlgebraicX.jl/blob/gh-pages/dev"
config["repo_root_url"] = "https://github.com/AlgebraicJulia/AlgebraicX.jl/blob/main/docs"
config["nbviewer_root_url"] = "https://nbviewer.jupyter.org/github/AlgebraicJulia/DiagrammaticEquations.jl/blob/gh-pages/dev"
config["repo_root_url"] = "https://github.com/AlgebraicJulia/DiagrammaticEquations.jl/blob/main/docs"
end

for (root, dirs, files) in walkdir(literate_dir)
Expand All @@ -36,11 +36,11 @@ end
makedocs(
modules=[DiagrammaticEquations],
format=Documenter.HTML(),
sitename="AlgebraicX.jl",
sitename="DE.jl",
doctest=false,
checkdocs=:none,
pages=Any[
"AlgebraicX.jl"=>"index.md",
"DiagrammaticEquations.jl"=>"index.md",
"Examples"=>Any[
"generated/literate_example.md",
],
Expand Down
2 changes: 1 addition & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Library Reference

```@autodocs
Modules = [DiagrammaticEquations]
Modules = [DiagrammaticEquations, DiagrammaticEquations.Deca, DiagrammaticEquations.Learn]
```
3 changes: 2 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
CurrentModule = DiagrammaticEquations
```

`DiagrammaticEquations.jl` is a Julia library for...
`DiagrammaticEquations.jl` is a Julia library implementing category-theoretic formally reasoning about systems of algebraic and differential equations with diagrams.

24 changes: 24 additions & 0 deletions jobscript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
#SBATCH --job-name=daemon_job_test # Job name
#SBATCH --mail-type=END,FAIL # Mail events (NONE, BEGIN, END, FAIL, ALL)
#SBATCH [email protected] # Where to send mail
#SBATCH --ntasks=1 # Run on a single CPU
#SBATCH --mem=8gb # Job memory request
#SBATCH --time=00:05:00 # Time limit hrs:min:sec
#SBATCH --output=daemon_test_%j.log # Standard output and error log
pwd; hostname; date

module load gcc/12.2.0 openmpi/4.1.5 julia

echo "Running docs build..."

julia --project=docs/ -e 'using Pkg; Pkg.status()'
julia --project=docs/ -e 'using Pkg; Pkg.instantiate(); include("docs/make.jl")'
# julia --project -e 'using Pkg; Pkg.status; Pkg.test()' > log_test.md
# ./job.sh

# mpiexec -np 1 julia --project -e test/runtests.jl

date


67 changes: 67 additions & 0 deletions src/DiagrammaticEquations.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
""" Some description of ths package
"""
module DiagrammaticEquations

export
DerivOp, append_dot, normalize_unicode, infer_states,
# Deca
recursive_delete_parents, findname, spacename,
op1_inf_rules_1D, op2_inf_rules_1D, op1_inf_rules_2D, op2_inf_rules_2D, op1_res_rules_1D, op2_res_rules_1D, op1_res_rules_2D, op2_res_rules_2D, varname,
## collages
Collage, collate,
## composition
oapply, unique_by, unique_by!, OpenSummationDecapodeOb, OpenSummationDecapode, Open,
## acset
unicode!,
SchDecapode, SchNamedDecapode, AbstractDecapode, AbstractNamedDecapode, NamedDecapode, SummationDecapode,
contract_operators, add_constant!, add_parameter, vec_to_dec!, infer_types!,
fill_names!, dot_rename!, expand_operators, infer_state_names, recognize_types,
resolve_overloads!,
## language
@decapode, Term, parse_decapode, term, Eq, DecaExpr,
# ~~~~~
Plus, AppCirc1, AppCirc2, Var, Tan, App1, App2, Judgment,
## visualization
to_graphviz_property_graph, typename,
## rewrite
average_rewrite


using Catlab
using Catlab.Theories
import Catlab.Theories: otimes, oplus, compose, ⊗, ⊕, ⋅, associate, associate_unit, Ob, Hom, dom, codom
using Catlab.Programs
using Catlab.CategoricalAlgebra
using Catlab.WiringDiagrams
using Catlab.WiringDiagrams.DirectedWiringDiagrams
using Catlab.ACSetInterface
using MLStyle
import Unicode

# using .Deca
# import .Deca: to_graphviz_property_graph


## TODO:
## generate schema from a _theory_
## from presentation in the theory determine what to slice over
## Pavel S., Hypergraph theory string diagram

normalize_unicode(s::String) = Unicode.normalize(s, compose=true, stable=true, chartransform=Unicode.julia_chartransform)
normalize_unicode(s::Symbol) = Symbol(normalize_unicode(String(s)))

DerivOp = Symbol("∂ₜ")
append_dot(s::Symbol) = Symbol(string(s)*'\U0307')


include("acset.jl")
include("language.jl")
include("composition.jl")
include("collages.jl")
include("visualization.jl")
include("rewrite.jl")

include("deca/Deca.jl")
include("learn/Learn.jl")

end
Loading
Loading