@@ -12,64 +12,64 @@ 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, ` models/{model_name}.jl ` .
15
+ You can modify the list of models by:
16
16
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.**
18
19
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:
23
26
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
+ =#
26
31
27
- # (3) Define data if necessary
28
- data = ...
32
+ # (2) Imports if necessary
33
+ using MyOtherPackage : some_function
29
34
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 = ...
35
37
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
39
43
40
- ** (1) Model name**
44
+ # (5) Instantiate the model
45
+ model = model_name (data, ... )
46
+ ```
41
47
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**
44
49
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.
46
52
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**
49
54
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 .)
52
57
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 ` .)
54
60
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 **
56
62
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.
58
64
59
- Models can be defined as usual with ` @model function model_name(...) ` .
65
+ ** (4) Model definition **
60
66
61
- ** (5) Model instantiation **
67
+ Models can be defined as usual with ` @model function model_name(...) ` .
62
68
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**
65
70
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 ` .)
73
73
74
74
> [ !IMPORTANT]
75
75
> 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
78
78
> - The filename i.e. ` models/model_name.jl `
79
79
> - The name of the model in ` main.jl ` i.e. ` @include_model "Category Heading" "model_name" `
80
80
81
- (This setup does admittedly feel a bit complicated .
81
+ (This setup does admittedly feel a bit fragile .
82
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
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.)
84
84
0 commit comments