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

I want a Plugin root key and schema #500

Merged
merged 81 commits into from
May 25, 2023

Conversation

cvchaparro
Copy link
Contributor

@cvchaparro cvchaparro commented Apr 26, 2023

As a plugin developer, I want a dedicated root key and schema for defining plugins, so that I have a clearer and more explicit definition of what my plugin does.

AC:

  • In the core spec there is a new schema defined Plugin
  • In the core spec, root keys defines a new entry plugin with the new Plugin type
  • There is a new PluginContributions enum which provides a list of enums for each of the plugin contribution types.
  • There is a new schema PluginCommand that has the following fields:
    • Group - A string indicating the command's group name
    • Input
    • Output
  • The new schema Plugin has the following fields
    • name - The name for the plugin
    • commands - An optional list of Behavior entries
    • additional_definition_resources - An optional list of files that contain the plugin-provided definitions
    • primitive_validations - An optional list of primitive-type validators
    • definition_validations - An optional list of definition-type validators
  • The Gen-Plugin plugin is updated to use the new schema
  • Existing plugins have their definitions updated

@Coffee2Bits Coffee2Bits added draft This issue is a draft version. chore An enhancement that isn't user-facing labels Dec 5, 2022
@Coffee2Bits Coffee2Bits added this to Backlog in AaC Prototype via automation Dec 5, 2022
@cvchaparro
Copy link
Contributor

I've come across another place where I think this Plugin schema will allow us to enhance our plugin definitions.

The specific example comes from the list-plugins command which only has optional arguments (i.e. --all, --active, and --inactive) but requires at least one option to be provided. As it currently stands, if no option is provided, we proceed to delegate to the command as opposed to displaying the command's usage because we don't have a way to distinguish between a command where all arguments are optional and the case where the command has only optional arguments but at least one is required. Currently, this is the only plugin command we have that has this constraint but I can easily see it being necessary in for future commands, as well.

My suggestion would be that we change how we define the commands field so that it is an optional list of CommandBehavior entries (or some such structure extending Behavior) where one of the fields in CommandBehavior is whether at least one argument is required. One option could be to make this an optional field whose value automatically defaults to whatever value is most common (probably True) and is set to False for commands like version, etc that don't require any arguments.

@jondavid-black
Copy link
Collaborator

The plugin scheme needs a field to allow for new schemas and extensions to be defined as well. At least for my use cases, one of the most common needs is to establish a schema to extend existing AaC or create new domain specific model definitions.

@Coffee2Bits Coffee2Bits changed the title I want a Plugin key root and schema I want a Plugin root key and schema Feb 13, 2023
@Coffee2Bits Coffee2Bits removed the draft This issue is a draft version. label Apr 19, 2023
@Coffee2Bits Coffee2Bits moved this from Backlog to To do in AaC Prototype Apr 20, 2023
@Coffee2Bits Coffee2Bits moved this from To do to In progress in AaC Prototype Apr 20, 2023
@cvchaparro cvchaparro mentioned this pull request May 16, 2023
9 tasks
Copy link
Contributor

@Coffee2Bits Coffee2Bits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Instead of the helper IO and IO2 modules, can we rename IO -> IO_DEP and IO2-> IO?

AaC Prototype automation moved this from In progress to In Review May 17, 2023
@cvchaparro cvchaparro changed the base branch from main to pre-release-v0.2.0 May 17, 2023 17:31
Also, since we're already touching these files go ahead and change references
from temporary_test_file to TemporaryTestFile.
Copy link
Contributor

@Coffee2Bits Coffee2Bits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Only change would be to use enums to select the Temp file mode instead of strings.

python/tests/helpers/io/TemporaryTestFile.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Coffee2Bits Coffee2Bits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

AaC Prototype automation moved this from In Review to Ready for Merge May 25, 2023
@cvchaparro cvchaparro merged commit ab40c1f into pre-release-v0.2.0 May 25, 2023
18 checks passed
AaC Prototype automation moved this from Ready for Merge to Done May 25, 2023
@cvchaparro cvchaparro deleted the 500-i-want-a-plugin-root-key-and-schema branch May 25, 2023 19:30
@Coffee2Bits Coffee2Bits mentioned this pull request Jun 23, 2023
9 tasks
lizzcondrey pushed a commit that referenced this pull request Jun 26, 2023
* I want a `Plugin` root key and schema (#500)

* Add Plugin and PluginCommand to spec.yaml

* Update describe-definition to take a reference

* Make ValidationReference and DefinitionReference actual references

* Spelling

* Improve naming

* Add command group schema and update plugin command schema

* Add a display name to command groups

* Add a display name to commands

* Update the gen-plugin architecture definition

* Update references.py

Clean up, refactor, and fix tests.

* Replace hard-coded string values with constants

* Update material model plugin definition

* Update commandGroup description

* Convert version plugin definition

* Convert validate plugin definition

* Fix goto definition test

* Convert gen_design_doc plugin definition

* Convert active_context plugin definition

* Put common command group definitions in spec.yaml

* Convert gen_gherkin_behaviors plugin definition

* Convert gen_json plugin definition

* Convert gen_protobuf plugin definition

* Convert help_dump plugin definition

* Convert gen_plant_uml plugin definition

* Convert lsp_server plugin definition

* Convert plugin_management plugin definition

* Convert print_spec plugin definition

* Convert rest_api plugin definition

* Convert specifications plugin definition

* Put descriptions on the same line

* Dedup constants that refer to the import root key

* Fix gen-protobuf test and minor cleanup

* More fixes for gen-gherkin-behaviors

* Keep up with spec.yaml changes

* Fix reference tests

* Update validator plugin definitions

* Make plugin definition files consistent

* Update definitions for primitive type checking plugin

* Update validators

Also, make the `when' step of validators read the same.

* Update docs

* Update plugin names in implementation files

* Fix imports

* Fix test file names

* Fix plugin management plugin tests

* Fix gen-design-doc generated output after template engine changes

A while ago we made changes to the template engine that made it so that we
didn't have to do as much spacing management in templates and this plugin never
got updated.

* Fix tests failing as a result of plugin name update

Now that plugin name doesn't necessarily equal the validation name for
validations, we need a way to distinguish between them.

* Rename usage of generate-openapi-spec to gen-openapi-spec

Update the OpenAPI spec generation command name for consistency with other
generation commands.

* Update plugin.yaml

Update the test plugin file to fully exercise plugin generation features.

* Add a few more definition field constants

* Update gen-plugin and tests

* Fix name

* Use updated field

* Put test helpers in another package

* Specify VALIDATION_NAME for each plugin

* Add description for `name' argument

* Add the right command dictionary

* Update clear_directory

* Initial updates to templates to acommodate new plugin format

* Updates gen plugin and tests

Update test with correct number of plugin files.

Move all plugin definition source files to the plugin directory for third-party
plugins.

* Fix things

* Try fixing docstring, again

* Updates to the pipeline

* Test plugin definition file updates

Add the test validation definitions.

Use relative file path on definition source value.

Switch command from description to helpText.

* Ignore D417 warnings in tests/ directory

* Update gen-openapi-spec command name

* Update validator implementation validation

We only need to care about validation implementations that are contributed by
active plugins.

* Update pipeline

* Fix flake8 warnings

* Fix command name

* Just use constructor for validation contributions

* Update validate validator implementation test

* Address the comment for TemporaryTestFile

* Fix parameters

* Fixes to TemporaryTestFile

* Update tests.helpers.io package

Also, since we're already touching these files go ahead and change references
from temporary_test_file to TemporaryTestFile.

* Use validator.optional

* Apply suggestions from code review

* Use an Enum instead of strings for the clean_up option

* Remove workaround for missing validator implementations in tests

* Promote specifications to core aac language (#559)

* initial mods, no testing yet

* removed commented out code

* Add Plugin and PluginCommand to spec.yaml

* Update describe-definition to take a reference

* Make ValidationReference and DefinitionReference actual references

* Spelling

* Improve naming

* Add command group schema and update plugin command schema

* Add a display name to command groups

* Add a display name to commands

* Update the gen-plugin architecture definition

* Update references.py

Clean up, refactor, and fix tests.

* Replace hard-coded string values with constants

* Update material model plugin definition

* Update commandGroup description

* Convert version plugin definition

* Convert validate plugin definition

* Fix goto definition test

* Convert gen_design_doc plugin definition

* Convert active_context plugin definition

* Put common command group definitions in spec.yaml

* Convert gen_gherkin_behaviors plugin definition

* Convert gen_json plugin definition

* Convert gen_protobuf plugin definition

* Convert help_dump plugin definition

* Convert gen_plant_uml plugin definition

* Convert lsp_server plugin definition

* Convert plugin_management plugin definition

* Convert print_spec plugin definition

* Convert rest_api plugin definition

* Convert specifications plugin definition

* Put descriptions on the same line

* Dedup constants that refer to the import root key

* Fix gen-protobuf test and minor cleanup

* More fixes for gen-gherkin-behaviors

* Keep up with spec.yaml changes

* Fix reference tests

* Update validator plugin definitions

* Make plugin definition files consistent

* Update definitions for primitive type checking plugin

* Update validators

Also, make the `when' step of validators read the same.

* Update docs

* Update plugin names in implementation files

* Fix imports

* Fix test file names

* Fix plugin management plugin tests

* Fix gen-design-doc generated output after template engine changes

A while ago we made changes to the template engine that made it so that we
didn't have to do as much spacing management in templates and this plugin never
got updated.

* Fix tests failing as a result of plugin name update

Now that plugin name doesn't necessarily equal the validation name for
validations, we need a way to distinguish between them.

* Rename usage of generate-openapi-spec to gen-openapi-spec

Update the OpenAPI spec generation command name for consistency with other
generation commands.

* Update plugin.yaml

Update the test plugin file to fully exercise plugin generation features.

* Add a few more definition field constants

* Update gen-plugin and tests

* Fix name

* Use updated field

* Put test helpers in another package

* Specify VALIDATION_NAME for each plugin

* Add description for `name' argument

* Add the right command dictionary

* Update clear_directory

* Initial updates to templates to acommodate new plugin format

* Updates gen plugin and tests

Update test with correct number of plugin files.

Move all plugin definition source files to the plugin directory for third-party
plugins.

* Fix things

* Try fixing docstring, again

* Updates to the pipeline

* Test plugin definition file updates

Add the test validation definitions.

Use relative file path on definition source value.

Switch command from description to helpText.

* Ignore D417 warnings in tests/ directory

* Update gen-openapi-spec command name

* Update validator implementation validation

We only need to care about validation implementations that are contributed by
active plugins.

* Update pipeline

* Fix flake8 warnings

* Fix command name

* Just use constructor for validation contributions

* Update validate validator implementation test

* Address the comment for TemporaryTestFile

* Fix parameters

* Fixes to TemporaryTestFile

* Update tests.helpers.io package

Also, since we're already touching these files go ahead and change references
from temporary_test_file to TemporaryTestFile.

* Use validator.optional

* Apply suggestions from code review

* Fix tests after merging

* Rename usages of DEFINITION_NAME_SCHEMA to ROOT_KEY_SCHEMA

* Remove original test_gen_plugin in favor of test_gen_plugin_impl

* Update requirement-related validations

* Fix validators

* Use an Enum instead of strings for the clean_up option

* Remove workaround for missing validator implementations in tests

* Fix test failures

* Simplify

* Clean up

---------

Co-authored-by: Cameron Chaparro <cameron.chaparro@zadentech.com>
Co-authored-by: Cameron Chaparro <cvchaparro@users.noreply.github.com>

* Make the import keyword a file wide declaration (#612)

* Update import root key in spec

* Update parser tests

Fix constant names and use the file name constants to define imports.

* Update gen_plugin tests

* Fix goto definition test

* Update parser handling of imports

* Update document link provider

* Fix the document link provider test

* Formatting

* Make sure we handle multiple import definitions per file

My intuition tells me this would be an antipattern but I think we should handle
that using a linting validator, rather than throwing an error.

* Update imports in models

* Make sure we provide imports list as a field

* Minor doc updates

* Add comments to documentation about imports

* Update docs

* Update spec.yaml with a definition structure for imports

* Update import references in definition files

* Update imports to use the new files field

* Update docstring

* Update README.md

* 615 remove the material plugin (#616)

* removed material plugin

* remove unit test and sample model

* disabled test that relied on material plugin model

* Removed skip test annotation and got the test working.

---------

Co-authored-by: Alex Monnet <alexcmonnet@gmail.com>

* AaC Style Guide (#613)

* Added user documentation on the AaC DSL Style Guide

Co-authored-by: Cameron Chaparro <cvchaparro@users.noreply.github.com>

* Update Core Spec to adhere to the Style Guide (#619)

* Updated the Core Spec to adhere to the AaC Style Guide
* Updated example models to adhere to the AaC Style Guide
* Updated first-party plugins to adhere to the AaC Style Guide

Co-authored-by: Cameron Chaparro <cvchaparro@users.noreply.github.com>

* Version bump

* Update Extension test

* Removed duplication spec consant

* Update dupe spec reference

* Removed unused constant

* Update gen puml yaml to use commands

* Readded nixed file docstring

* Moved genjson to commands

* Added parser error handling in line with the YAML error handling.

* Fixed parser import

---------

Co-authored-by: Cameron Chaparro <cvchaparro@users.noreply.github.com>
Co-authored-by: Cameron Chaparro <cameron.chaparro@zadentech.com>
Co-authored-by: Jondavid Black <36022341+jondavid-black@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore An enhancement that isn't user-facing
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants