Skip to content

Commit

Permalink
feat(doc): update README.md file according to redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
narekhovhannisyan committed Oct 4, 2024
1 parent a5bd1c5 commit 778638f
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ Here can be implementation details of the plugin. For example which API is used,

## Usage

To run the `<YOUR-CUSTOM-PLUGIN>`, an instance of `PluginInterface` must be created. Then, the plugin's `execute()` method can be called, passing required arguments to it.
To run the `<YOUR-CUSTOM-PLUGIN>`, an instance of `PluginFactory` must be created. Then, the plugin's `execute()` method can be called, passing required arguments to it.

This is how you could run the model in Typescript:
This is how you could run the plugin in Typescript:

```typescript
async function runPlugin() {
const newPlugin = await new MyCustomPlugin().configure(params);
const usage = await newPlugin.calculate([
const usage = await MyCustomPlugin({}).execute([
{
timestamp: '2021-01-01T00:00:00Z',
duration: '15s',
Expand All @@ -34,16 +33,16 @@ async function runPlugin() {
runPlugin();
```

## Testing model integration
## Testing plugin integration

>Note: [If Core](https://github.com/Green-Software-Foundation/if-core) plugin has a set of error classes which should be used for having necessary integration with the IF framework. More information on error classes can be found at [Errors Reference](https://if.greensoftware.foundation/reference/errors/).
### Using local links

For using locally developed model in `IF Framework` please follow these steps:
For using locally developed plugin in `IF Framework` please follow these steps:

1. On the root level of a locally developed model run `npm link`, which will create global package. It uses `package.json` file's `name` field as a package name. Additionally name can be checked by running `npm ls -g --depth=0 --link=true`.
2. Use the linked model in impl by specifying `name`, `method`, `path` in initialize models section.
1. On the root level of a locally developed plugin run `npm link`, which will create global package. It uses `package.json` file's `name` field as a package name. Additionally name can be checked by running `npm ls -g --depth=0 --link=true`.
2. Use the linked plugin in manifest by specifying `name`, `method`, `path` in initialize plugins section.

```yaml
name: plugin-demo-link
Expand All @@ -54,23 +53,23 @@ initialize:
my-custom-plugin:
method: MyCustomPlugin
path: "<name-field-from-package.json>"
global-config:
config:
...
...
```

### Using directly from Github

You can simply push your model to the public Github repository and pass the path to it in your impl.
For example, for a model saved in `github.com/my-repo/my-model` you can do the following:
You can simply push your plugin to the public Github repository and pass the path to it in your manifest.
For example, for a plugin saved in `github.com/my-repo/my-plugin` you can do the following:

npm install your model:
npm install your plugin:

```
npm install -g https://github.com/my-repo/my-model
npm install -g https://github.com/my-repo/my-plugin
```

Then, in your `impl`, provide the path in the model instantiation. You also need to specify which class the model instantiates. In this case you are using the `PluginInterface`, so you can specify `OutputModel`.
Then, in your `manifest`, provide the path in the plugin instantiation. You also need to specify which method the plugin instantiates. In this case you are using the `MyCustomPlugin`.

```yaml
name: plugin-demo-git
Expand All @@ -80,14 +79,14 @@ initialize:
plugins:
my-custom-plugin:
method: MyCustomPlugin
path: https://github.com/my-repo/my-model
path: https://github.com/my-repo/my-plugin
global-config:
...
...
```

Now, when you run the `manifest` using the IF CLI, it will load the model automatically. Run using:
Now, when you run the `manifest` using the IF CLI, it will load the plugin automatically. Run using:

```sh
ie --manifest <path-to-your-impl> --output <path-to-save-output>
if --m <path-to-your-manifest> -o <path-to-save-output>
```

0 comments on commit 778638f

Please sign in to comment.