Skip to content

Commit ed99c62

Browse files
committed
Update README
1 parent 86d3f0d commit ed99c62

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

README.md

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,64 +12,64 @@ You can modify the list of AD types in `main.jl`.
1212

1313
## I want to add more models!
1414

15-
You can modify the list of models by adding a new file, `models/{model_name}.jl`.
15+
You can modify the list of models by:
1616

17-
The basic structure of this file should look like this, where `model_name` is replaced accordingly:
17+
1. Adding a new call to `@include_model {category_heading} {model_name}` in `main.jl`.
18+
**Both `category_heading` and `model_name` should be strings.**
1819

19-
```julia
20-
#=
21-
(1) You can add any explanatory comments here if necessary
22-
=#
20+
`category_heading` is used to determine which table the model appears under on the website.
21+
This should be self-explanatory if you look at the [current website](https://turinglang.org/ADTests).
22+
23+
2. Adding a new file, `models/{model_name}.jl`.
24+
25+
The basic structure of this file should look like this, where `model_name` is replaced accordingly:
2326

24-
# (2) Imports if necessary
25-
using MyOtherPackage: some_function
27+
```julia
28+
#=
29+
(1) You can add any explanatory comments here if necessary
30+
=#
2631

27-
# (3) Define data if necessary
28-
data = ...
32+
# (2) Imports if necessary
33+
using MyOtherPackage: some_function
2934

30-
# (4) Define the model
31-
@model function model_name(data, ...)
32-
# Define your model here
33-
...
34-
end
35+
# (3) Define data if necessary
36+
data = ...
3537

36-
# (5) Instantiate the model
37-
model = model_name(data, ...)
38-
```
38+
# (4) Define the model
39+
@model function model_name(data, ...)
40+
# Define your model here
41+
...
42+
end
3943

40-
**(1) Model name**
44+
# (5) Instantiate the model
45+
model = model_name(data, ...)
46+
```
4147

42-
Ideally, `model_name` would be self-explanatory, i.e. it would serve to illustrate exactly one feature and the name would indicate this.
43-
However, if necessary, you can add further explanatory comments inside the model definition file.
48+
**(1) Model name**
4449

45-
**(2) Dependencies**
50+
Ideally, `model_name` would be self-explanatory, i.e. it would serve to illustrate exactly one feature and the name would indicate this.
51+
However, if necessary, you can add further explanatory comments inside the model definition file.
4652

47-
Inside this file, you do not need to call `using Turing` or any of the AD backends.
48-
(This also means you do not need to import anything that Turing re-exports, such as distributions.)
53+
**(2) Dependencies**
4954

50-
However, you will have to make sure to import any other packages that your model requires.
51-
(If this package is not already present in the project environment, you will also have to add it to `Project.toml`.)
55+
Inside this file, you do not need to call `using Turing` or any of the AD backends.
56+
(This also means you do not need to import anything that Turing re-exports, such as distributions.)
5257

53-
**(3) Data definition**
58+
However, you will have to make sure to import any other packages that your model requires.
59+
(If this package is not already present in the project environment, you will also have to add it to `Project.toml`.)
5460

55-
Each file in `models/` is evaluated within its own module, so you can declare data variables, etc. without worrying about name clashes.
61+
**(3) Data definition**
5662

57-
**(4) Model definition**
63+
Each file in `models/` is evaluated within its own module, so you can declare data variables, etc. without worrying about name clashes.
5864

59-
Models can be defined as usual with `@model function model_name(...)`.
65+
**(4) Model definition**
6066

61-
**(5) Model instantiation**
67+
Models can be defined as usual with `@model function model_name(...)`.
6268

63-
The last line in the file should be the creation of the Turing model object using `model = model_name(...)`.
64-
(It is mandatory for the model object to be called `model`.)
69+
**(5) Model instantiation**
6570

66-
**Inclusion in `main.jl`**
67-
68-
Finally, inside `main.jl`, add a call to `@include_model category_heading model_name`.
69-
**Both `category_heading` and `model_name` should be strings.**
70-
71-
`category_heading` is used to determine which table the model appears under on the website.
72-
This should be self-explanatory if you look at the [current website](https://turinglang.org/ADTests).
71+
The last line in the file should be the creation of the Turing model object using `model = model_name(...)`.
72+
(It is mandatory for the model object to be called `model`.)
7373

7474
> [!IMPORTANT]
7575
> Note that for CI to run properly, `model_name` **must** be consistent between the following:
@@ -78,7 +78,7 @@ This should be self-explanatory if you look at the [current website](https://tur
7878
> - The filename i.e. `models/model_name.jl`
7979
> - The name of the model in `main.jl` i.e. `@include_model "Category Heading" "model_name"`
8080
81-
(This setup does admittedly feel a bit complicated.
81+
(This setup does admittedly feel a bit fragile.
8282
Unfortunately I could not find a simpler way to get all the components (Julia, Python, web app) to work together in an automated fashion.
8383
Hopefully it is a small price to pay for the ability to just add a new model and have it be automatically included on the website.)
8484

0 commit comments

Comments
 (0)