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

Model example library for testing #157

Merged
merged 18 commits into from
Feb 21, 2024
Merged

Conversation

PedroGGBM
Copy link
Contributor

Original issue #65:

The minion bindings should have fully runnable and testable documentation examples.

As suggested by Chris Jefferson, having a library of example models would cut down on code duplication in these doctests.

This should take the form of a public module inside the crate with functions such as:

examples::bibd_model()
examples::xyz_model()

This should be used to rewrite the example for the callback type. This example needn't include details of model construction (it is primarily concerned with how you print the results at the end) , so it is an ideal candidate for using an example model.

Also potentially add some model building shortcut functions, such as making n variables of domain 0..m..

@lixitrixi
Copy link
Contributor

Just wanted to add what we discussed today and submit it to peer review:

I was thinking a clean way to approach this "example registry" would be with a get_example_model function, which accepts a string, loads the corresponding .essence file from a hard-coded directory, parses it through conjure/json, and returns it, rather than hard-coded example constants.

This would mean we can create examples before/while adding support for certain AST variants. It would also force us to implement the parser for each new AST extension ASAP, which I personally think is a good thing.

@ozgurakgun what do you think?

@ozgurakgun
Copy link
Contributor

Great idea! It'll make adding new examples a lot easier.

@niklasdewally niklasdewally linked an issue Jan 31, 2024 that may be closed by this pull request
@niklasdewally niklasdewally added area::conjure-oxide Related to conjure_oxide. kind::testing Testing and Correctness labels Feb 13, 2024
@ozgurakgun
Copy link
Contributor

ozgurakgun commented Feb 16, 2024 via email

@PedroGGBM PedroGGBM marked this pull request as ready for review February 19, 2024 19:55
@lixitrixi
Copy link
Contributor

CI is failing because of the following error:

Unhandled error: HttpError: Resource not accessible by integration

This seems to be a CI issue? Not sure what's going on. @niklasdewally

@niklasdewally
Copy link
Contributor

CI is failing because of the following error:

Unhandled error: HttpError: Resource not accessible by integration

This seems to be a CI issue? Not sure what's going on. @niklasdewally

Already discussed this with @PedroGGBM over teams - there seems to be a duplicate version of the "code and documentation coverage" ci in this PR from when Pedro was experimenting with it.

@PedroGGBM if you just delete the yaml file of the broken workflow it should just disappear.

@ozgurakgun
Copy link
Contributor

rm the conjure-output folder

Copy link
Contributor

Documentation Coverage

This PR
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| ...jure_rules_proc_macro/src/lib.rs |          1 |      50.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          1 |      50.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| ...es/doc_solver_support/src/lib.rs |          1 |      50.0% |          1 |      50.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          1 |      50.0% |          1 |      50.0% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| crates/conjure_rules/src/lib.rs     |          2 |      66.7% |          1 |      33.3% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          2 |      66.7% |          1 |      33.3% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| crates/conjure_core/src/ast.rs      |         12 |      26.1% |          0 |       0.0% |
| crates/conjure_core/src/lib.rs      |          0 |       0.0% |          0 |       0.0% |
| crates/conjure_core/src/metadata.rs |          0 |       0.0% |          0 |       0.0% |
| crates/conjure_core/src/rule.rs     |          0 |       0.0% |          0 |       0.0% |
| crates/conjure_core/src/solvers.rs  |          2 |      40.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |         14 |      21.9% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| crates/uniplate/src/lib.rs          |          1 |     100.0% |          1 |     100.0% |
| crates/uniplate/src/uniplate.rs     |          7 |      70.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          8 |      72.7% |          1 |       9.1% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| solvers/kissat/src/lib.rs           |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| solvers/minion/src/ast.rs           |          4 |       4.1% |          0 |       0.0% |
| solvers/minion/src/error.rs         |          5 |      62.5% |          0 |       0.0% |
| solvers/minion/src/lib.rs           |          1 |     100.0% |          1 |     100.0% |
| solvers/minion/src/run.rs           |          2 |     100.0% |          1 |     100.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |         12 |      11.0% |          2 |      11.8% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| conjure_oxide/src/error.rs          |          1 |      14.3% |          0 |       0.0% |
| conjure_oxide/src/find_conjure.rs   |          1 |      50.0% |          0 |       0.0% |
| ...ure_oxide/src/generate_custom.rs |          2 |      66.7% |          0 |       0.0% |
| conjure_oxide/src/lib.rs            |          0 |       0.0% |          0 |       0.0% |
| conjure_oxide/src/parse.rs          |          0 |       0.0% |          0 |       0.0% |
| conjure_oxide/src/rewrite.rs        |          2 |      66.7% |          0 |       0.0% |
| conjure_oxide/src/rules/constant.rs |          1 |     100.0% |          0 |       0.0% |
| conjure_oxide/src/solvers/error.rs  |          0 |       0.0% |          0 |       0.0% |
| conjure_oxide/src/solvers/kissat.rs |          1 |      14.3% |          0 |       0.0% |
| conjure_oxide/src/solvers/minion.rs |          1 |     100.0% |          0 |       0.0% |
| conjure_oxide/src/solvers/mod.rs    |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          9 |      26.5% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| ...932d5ea6/out/chuffed_bindings.rs |          0 |       0.0% |          0 |       0.0% |
| solvers/chuffed/src/lib.rs          |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
Main
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| ...es/doc_solver_support/src/lib.rs |          1 |      50.0% |          1 |      50.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          1 |      50.0% |          1 |      50.0% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| ...jure_rules_proc_macro/src/lib.rs |          1 |      50.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          1 |      50.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| crates/conjure_rules/src/lib.rs     |          2 |      66.7% |          1 |      33.3% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          2 |      66.7% |          1 |      33.3% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| crates/conjure_core/src/ast.rs      |         12 |      26.1% |          0 |       0.0% |
| crates/conjure_core/src/lib.rs      |          0 |       0.0% |          0 |       0.0% |
| crates/conjure_core/src/metadata.rs |          0 |       0.0% |          0 |       0.0% |
| crates/conjure_core/src/rule.rs     |          0 |       0.0% |          0 |       0.0% |
| crates/conjure_core/src/solvers.rs  |          2 |      40.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |         14 |      21.9% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| crates/uniplate/src/lib.rs          |          1 |     100.0% |          1 |     100.0% |
| crates/uniplate/src/uniplate.rs     |          7 |      70.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          8 |      72.7% |          1 |       9.1% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| solvers/minion/src/ast.rs           |          4 |       4.1% |          0 |       0.0% |
| solvers/minion/src/error.rs         |          5 |      62.5% |          0 |       0.0% |
| solvers/minion/src/lib.rs           |          1 |     100.0% |          1 |     100.0% |
| solvers/minion/src/run.rs           |          2 |     100.0% |          1 |     100.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |         12 |      11.0% |          2 |      11.8% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| conjure_oxide/src/error.rs          |          1 |      14.3% |          0 |       0.0% |
| conjure_oxide/src/find_conjure.rs   |          1 |      50.0% |          0 |       0.0% |
| conjure_oxide/src/lib.rs            |          0 |       0.0% |          0 |       0.0% |
| conjure_oxide/src/parse.rs          |          0 |       0.0% |          0 |       0.0% |
| conjure_oxide/src/rewrite.rs        |          2 |      66.7% |          0 |       0.0% |
| conjure_oxide/src/rules/constant.rs |          1 |     100.0% |          0 |       0.0% |
| conjure_oxide/src/solvers/error.rs  |          0 |       0.0% |          0 |       0.0% |
| conjure_oxide/src/solvers/kissat.rs |          1 |      14.3% |          0 |       0.0% |
| conjure_oxide/src/solvers/minion.rs |          1 |     100.0% |          0 |       0.0% |
| conjure_oxide/src/solvers/mod.rs    |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          7 |      22.6% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| solvers/kissat/src/lib.rs           |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| ...932d5ea6/out/chuffed_bindings.rs |          0 |       0.0% |          0 |       0.0% |
| solvers/chuffed/src/lib.rs          |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+

Code Coverage

This PR

  lines......: 80.4% (3291 of 4094 lines)
  functions..: 60.2% (309 of 513 functions)
  branches...: no data found

Main

  lines......: 80.8% (3232 of 4001 lines)
  functions..: 60.5% (305 of 504 functions)
  branches...: no data found

@ozgurakgun ozgurakgun merged commit fb407f3 into conjure-cp:main Feb 21, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area::conjure-oxide Related to conjure_oxide. kind::testing Testing and Correctness
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants