Skip to content

Commit

Permalink
Updating Autobrew docs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBurchLog committed May 22, 2024
1 parent 153b20c commit ef752b4
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 5 deletions.
3 changes: 3 additions & 0 deletions docs/plugins/plugin-developer-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ These guides provide gentle introductions to plugin development. They are intend

* link:../python/local-guide/[Python Plugin (Local)]
* link:../python/remote-guide/[Python Plugin (Remote)]
* link:../python/autobrew-guide/[Python Plugin (Autobrew)]

TIP: If you want to know what Beer Garden is all about, find the answer in link:/docs/startup/what-is-beergarden/[What is Beer Garden?] If you're looking for a concise survey of plugin developer options, checkout the link:../plugin-syntax-quick-reference/[Plugin Developer Syntax Guide]

Expand All @@ -18,3 +19,5 @@ These guides will dive into some of the more specific ways you can develop plugi
* How to run your plugin

TIP: If you don't know the difference between remote and local plugins, please check the link:../local-vs-remote/[local vs remote plugins docs]

TIP: If you have an external library that you want converted to a plugin, please checkout the Autobrew guide.
117 changes: 116 additions & 1 deletion docs/plugins/python/_includes/beer-conf.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ PLUGIN_ENTRY='main.py'
AUTO_BREW_MODULE="my.module"
# Autobrew class
AUTO_BREW_CLASS="class"
AUTO_BREW_CLASS="my_class"
----

In addition to the required fields, you may optionally provide other values to enhance your plugin. Each option is explained in more detail below.
Expand Down Expand Up @@ -50,6 +51,12 @@ REQUIRES=['foo']
# Additional Metadata you would like to add to the system
METADATA = {'foo': 'bar'}
# Autobrew ARG values to pass to AUTO_BREW_CLASS __init__
AUTO_BREW_ARGS = ["foo","bar"]
# Autobrew KWARG values to pass to AUTO_BREW_CLASS __init__
AUTO_BREW_KWARGS = {"key","value"}
----

=== NAME
Expand Down Expand Up @@ -174,4 +181,112 @@ If you are writing a plugin that interacts with other plugins, then you should n
REQUIRES=['foo']
----

=== AUTO_BREW_ARGS

The `AUTO_BREW_ARGS` field allows ARG values to be passed into the class initialization function

The `AUTO_BREW_ARGS` entry plays along with the `INSTANCES` entry. If there are multiple instances and the `AUTO_BREW_ARGS` is a list, Beer Garden assumes that you want to pass the value of `AUTO_BREW_ARGS` to each and every instance that is defined in the `INSTANCES` section. For example:

[source,python]
----
INSTANCES=['foo', 'bar']
AUTO_BREW_ARGS=['arg1', 'arg2']
AUTO_BREW_MODULE="my.module"
AUTO_BREW_CLASS="my_class"
----

Tells Beer Garden to start two instances of your plugin via:

[source,python]
----
my.module.my_class('arg1','arg2')
my.module.my_class('arg1','arg2')
----

If you want to give different instances different arguments, you could do the following:

[source,python]
----
INSTANCES = ['foo', 'bar', 'baz']
AUTO_BREW_ARGS = {
'foo': ['arg1', 'arg2'],
'bar': ['arg3'],
'baz': []
}
----

This will instruct Beer Garden to start 3 instances of your plugins via:

[source,python]
----
my.module.my_class('arg1','arg2')
my.module.my_class('arg3')
my.module.my_class()
----

If you define your `AUTO_BREW_ARGS` as a dictionary, then there really is no need to define the `INSTANCES`. So the previous example and this example are functionally equivalent:

[source,python]
----
PLUGIN_ARGS = {
'foo': ['arg1', 'arg2'],
'bar': ['arg3'],
'baz': []
}
----

=== AUTO_BREW_KWARGS

The `AUTO_BREW_KWARGS` field allows KARG values to be passed into the class initialization function.

The `AUTO_BREW_KWARGS` entry plays along with the `INSTANCES` entry. If there are multiple instances and the `AUTO_BREW_KWARGS` is a list, Beer Garden assumes that you want to pass the value of `AUTO_BREW_KWARGS` to each and every instance that is defined in the `INSTANCES` section. For example:

[source,python]
----
INSTANCES=['foo', 'bar']
AUTO_BREW_KWARGS={"key_1","value_1", "key_2","value_2"}
AUTO_BREW_MODULE="my.module"
AUTO_BREW_CLASS="my_class"
----

Tells Beer Garden to start two instances of your plugin via:

[source,python]
----
my.module.my_class(key_1='value_1', key_2='value_2')
my.module.my_class(key_1='value_1', key_2='value_2')
----

If you want to give different instances different arguments, you could do the following:

[source,python]
----
INSTANCES = ['foo', 'bar', 'baz']
AUTO_BREW_KWARGS = {
'foo': {"key_1","value_1", "key_2","value_2"},
'bar': {"key_3","value_3"},
'baz': []
}
----

This will instruct Beer Garden to start 3 instances of your plugins via:

[source,python]
----
my.module.my_class(key_1='value_1', key_2='value_2')
my.module.my_class(key_3='value_3')
my.module.my_class()
----

If you define your `AUTO_BREW_KWARGS` as a dictionary, then there really is no need to define the `INSTANCES`. So the previous example and this example are functionally equivalent:

[source,python]
----
AUTO_BREW_KWARGS = {
'foo': {"key_1","value_1", "key_2","value_2"},
'bar': {"key_3","value_3"},
'baz': []
}
----

And that's it!
15 changes: 11 additions & 4 deletions docs/plugins/python/autobrew-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:page-layout: docs
:includedir: _includes

The goal of this section is to help you utilize an exisitng class as a Plugin.
The goal of this section is to help you utilize an existing class as a Plugin.

It is important to note that Autobrew is only supported by what is loaded on the pythonpath. The folder that contains the beer.conf that utilizes the Autobrew features is loaded onto the pythonpath.

Expand All @@ -11,16 +11,23 @@ Autobrew will allow Beer Garden to evaluate the class object and automatically g
[TIP]
.Pros of using Autobrew
====
If your client/system class does not require additional configuraitons when setting up the Plugin object, this feature can streamline your development.
If your client/system class does not require additional configurations when setting up the Plugin object, this feature can streamline your development.
====

== Exisiting Class Implementation

Autobrew allows you to utilize exising class objects as a Plugin with no additional work. All it requires is the `beer.conf`!
Autobrew allows you to utilize existing class objects as a Plugin with no additional work. All it requires is the `beer.conf`!

=== Unique beer.conf fields

Autobrew supports all of the fields standard for beer.conf.
Autobrew supports all of the fields standard for beer.conf. The primary difference is that Autobrew has the additional fiels of:

- AUTO_BREW_MODULE
- AUTO_BREW_CLASS
- AUTO_BREW_ARGS
- AUTO_BREW_KARGS

Allowing for the class to be intialized with static ARGS/KWARGS.

== Plugin Configuration

Expand Down

0 comments on commit ef752b4

Please sign in to comment.