Skip to content

Commit

Permalink
add text on registering split action
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcaporaso committed Jul 23, 2024
1 parent 55922df commit 22366cf
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions book/plugins/tutorials/add-parallel-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,24 @@ Referring to the `_methods.py` file in {{ dwq2_add_parallel_pipeline_commit_2_ur
This is also a good time to write unit tests for your `chunked_sequences` function.
I recommend designing and implementing them yourself, but you can also refer to the tests that I wrote in `test_methods.py`.

### Registering the `chunk_sequences` Action

The `chunk_sequences` function will be used in our `search_and_summarize` Pipeline, and we therefore need to register it as a new Action on our plugin.
This is done in the typical way, and at this point you should be getting pretty good at this.

The one thing that we haven't done yet in other Actions is allow for an arbitrary number of outputs, which in this case will be the individual chunks of sequences.
The combination of the number of sequences in an input and the user-specified `chunk_size` will define how many outputs will be generated by a call to this action, so it's not possible for us to determine this when registering the action.
We therefore define our output type as a `Collection` of `FeatureData[Sequence]` artifacts, which we annotate as `Collection[FeatureData[Sequence]]` in the `outputs` dictionary.
To achieve this, import `Collections` from `qiime2.plugin` at the top of your `plugin_setup.py` file.
In your call to `plugin.methods.register_function`, you can then pass:

```python
outputs={'chunked_sequences': Collection[FeatureData[Sequence]]}
```

Using that tip to handle the generation of an arbitrary number of outputs, refer to the other actions that you've registered, and start implementing the registration step without referring to the code in `q2-dwq2`.
Once you've done that and have it working, take a look at my call to `plugin.methods.register_function` in the `plugin_setup.py` file of `q2-dwq2` to see if you missed anything that I included (I added the code in this commit: {{ dwq2_add_parallel_pipeline_commit_2_url }}).



**This section is still a work in progress.**

0 comments on commit 22366cf

Please sign in to comment.