Setup the repository

Develop the methodology

To do

This section is a stub.

All fences (thresholds) are inclusive (rather than exclusive) in Cardinal, to be consistent and to be easy to interpret. However, this means that, if the methodology identifies outliers using the interquartile range, and if the interquartile range is zero, then the indicator will always return a result. Therefore, the methodology must guard against this by returning nothing if the interquartile range is zero.

Assign a code

When adding an indicator that is not assigned a code among the resources of the Open Contracting Partnership (or if you don’t know):

Add boilerplate content

One-time setup

To install the requirements for automation, create a Python virtual environment and run:

pip install click

To perform these steps, run, replacing r999:

./manage.py add-indicator r999

The files created are explained in the next sections.

  • Create the new module, src/indicators/r999.rs:

    use serde_json::{Map, Value};
    
    use crate::indicators::{set_result, Calculate, Indicators, Settings};
    
    #[derive(Default)]
    pub struct R999 {
    }
    
    impl Calculate for R999 {
        fn new(settings: &mut Settings) -> Self {
            Self::default()
        }
    
        fn fold(&self, item: &mut Indicators, release: &Map<String, Value>, ocid: &str) {
        }
    
        fn reduce(&self, item: &mut Indicators, other: &mut Indicators) {
        }
    
        fn finalize(&self, item: &mut Indicators) {
        }
    }
    
  • Create the test input, tests/fixtures/indicators/R999.jsonl:

    {}
    
  • Create the test output, tests/fixtures/indicators/R999.expected:

    {}
    
  • Create the documentation page, docs/cli/indicators/R/999.md:

    # TODO The title of the indicator (R999)
    
    TODO A one-sentence description of the indicator.
    
    ## Methodology
    
    TODO
    
    :::{admonition} Example
    :class: seealso
    
    TODO
    :::
    
    :::{admonition} Why is this a red flag?
    :class: hint
    
    TODO
    :::
    
    <small>Based on "TODO" in [*TODO*](TODO).</small>
    
    ## Output
    
    The indicator's value is TODO.
    
    ## Configuration
    
    All configuration is optional. To override the default TODO:
    
    ```ini
    [R999]
    TODO
    ```
    
    ## Exclusions
    
    A contracting process is excluded if:
    
    - TODO
    
    ## Assumptions
    
    TODO
    
    ## Demonstration
    
    *Input*
    
    :::{literalinclude} ../../../examples/R/999.jsonl
    :language: json
    :::
    
    *Output*
    
    ```console
    $ ocdscardinal indicators --settings docs/examples/settings.ini --no-meta docs/examples/R/999.jsonl
    {}
    
    ```
    
  • Create the demonstration input, docs/examples/R/999.jsonl:

    {}
    
  • In src/indicators/mod.rs:

    • Declare the new module in alphabetical order at the top of the file:

      pub mod r999;
      
    • Add a field to the Settings struct. This field is explained in the next section.

          pub R999: Option<Empty>,
      
    • Add a variant to the Indicator enum. The variants are keys in the JSON output of the indicators command:

          R999,
      
  • In src/lib.rs:

    • Import the new struct from the new module in alphabetical order at the top of the file:

      use crate::indicators::r999::R999;
      
    • Add the new struct in alphabetical order to the add_indicators! macro call:

                  R999,
      
  • In docs/examples/settings.ini, add a section for the new indicator in alphabetical order:

    [R999]
    

Try it!

If you run:

cargo test

All tests should pass! (with warnings about unused variables and imports)

Next step

Now, you can code the indicator.