@@ -12,31 +12,75 @@ You can modify the list of AD types in `main.jl`.
12
12
13
13
## I want to add more models!
14
14
15
- You can modify the list of models by adding a new file inside the ` models ` directory.
15
+ You can modify the list of models by:
16
16
17
- Inside this file, you do not need to call ` using Turing ` or any of the AD backends.
18
- However, you will have to make sure to import any other packages that your model uses .
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 .
19
19
20
- This file should have, as the final line, the creation of the Turing model object using ` model = model_f(...) ` .
21
- (It is mandatory for the model object to be called ` model ` .)
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:
22
26
23
- Then, inside ` main.jl ` , call ` @include_model category_heading model_name ` .
27
+ ``` julia
28
+ #=
29
+ (1) You can add any explanatory comments here if necessary
30
+ =#
24
31
25
- - ` category_heading ` is a string that is used to determine which table the model appears under on the website.
26
- - For the automated tests to run properly, ` model_name ` ** must** be consistent between the following:
27
- - The name of the model itself i.e. ` @model function model_name(...) `
28
- - The filename i.e. ` models/model_name.jl `
29
- - The name of the model in ` main.jl ` i.e. ` @include_model "Category Heading" model_name `
32
+ # (2) Imports if necessary
33
+ using MyOtherPackage: some_function
30
34
31
- Ideally, ` model_name ` would be self-explanatory, i.e. it would serve to illustrate exactly one feature and the name would indicate this.
32
- However, if necessary, you can add explanatory comments inside the model definition file .
35
+ # (3) Define data if necessary
36
+ data = .. .
33
37
34
- You can see the existing files in that directory for examples.
38
+ # (4) Define the model
39
+ @model function model_name (data, ... )
40
+ # Define your model here
41
+ ...
42
+ end
35
43
36
- > [ !NOTE]
37
- > This setup does admittedly feel a bit complicated.
38
- > Unfortunately I could not find a simpler way to get all the components (Julia, Python, web app) to work together in an automated fashion.
39
- > 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.
44
+ # (5) Instantiate the model
45
+ model = model_name (data, ... )
46
+ ```
47
+
48
+ ** (1) Description**
49
+
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.
52
+
53
+ ** (2) Dependencies**
54
+
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.)
57
+
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 ` .)
60
+
61
+ ** (3) Data definition**
62
+
63
+ Each file in ` models/ ` is evaluated within its own module, so you can declare data variables, etc. without worrying about name clashes.
64
+
65
+ ** (4) Model definition**
66
+
67
+ Models can be defined as usual with ` @model function model_name(...) ` .
68
+
69
+ ** (5) Model instantiation**
70
+
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 ` .)
73
+
74
+ > [ !IMPORTANT]
75
+ > Note that for CI to run properly, ` model_name ` ** must** be consistent between the following:
76
+ >
77
+ > - The name of the model itself i.e. ` @model function model_name(...) `
78
+ > - The filename i.e. ` models/model_name.jl `
79
+ > - The name of the model in ` main.jl ` i.e. ` @include_model "Category Heading" "model_name" `
80
+
81
+ (This setup does admittedly feel a bit fragile.
82
+ Unfortunately I could not find a simpler way to get all the components (Julia, Python, web app) to work together in an automated fashion.
83
+ 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.)
40
84
41
85
## I want to edit the website!
42
86
0 commit comments