usnistgov / dioptra

Test Software for the Characterization of AI Technologies
https://pages.nist.gov/dioptra/
Other
220 stars 33 forks source link

Design and document a contract for the structure of a Dioptra plugin #587

Closed keithmanville closed 2 months ago

keithmanville commented 2 months ago

In order to import plugins from a git repository we need to document and define the expected structure of a plugin repository and any assumptions being made.

This is a planning and design task. The finalized Dioptra plugin contract will eventually be part of the Dioptra documentation once the import and sync features are implemented.

keithmanville commented 2 months ago

This documents the structure and assumptions made in an external git repository containing dioptra plugin(s). This is a draft representing our current thinking. It will likely be refined as we work on the implementation.

The source of a dioptra plugin can be a git repository or a file upload.

The import and sync workflows will look for a dioptra.toml file in the root of the git repository (or optionally, the provided path in the URI). The dioptra.toml provides the configuration of the dioptra plugins present in this repository. We chose toml as the preferred config file format because it is human readable and writable and is part of the Python standard library.

This is a rough example of what the dioptra.toml file could look like for a simple hello_world plugin:

[plugins]

[plugins.hello_world]
path = "./hello_world" # recursively find all .py files

[[plugins.hello_world.tasks]]
name = "hello.greet"
description = "Print a greeting"

input_params = [
  { name = "greeting", type = "image" },
  { name = "name", type = "string" },
]
output_params = [ { name = "message", type = "string" } ]

[param_types]

# not relevant to the hello world example, but demonstrates how we could specify a custom structure
image = { structure = { list = ["int", "int", "int"], required = true } }

[entrypoints]

[entrypoints.greetings]
task_graph = "./entrypoints/hello-world.yaml"
plugins = [ "hello_world" ]

Note: we plan to use the same import and sync system for entrypoints in the future, but that functionality will not be included in the initial implementation.