Creating an Operator
If you would like to integrate your pipeline into Beagle with an Operator, please follow this guide
1. Setup
Setup a local instance of Beagle (see https://github.com/mskcc/beagle#setup). Make sure to point to the staging Ridgeback instance using RIDGEBACK_ environment variables
2. Create Test Fixtures
Create test objects for the models that your operator will require
Most likely you will need to create Pipeline, Port, Operator, and File objects
Use Django fixtures, preferably in JSON format
Try to emulate how the data will look in the database for a real run. For example if a File has a sample ID, try to use one that is formatted similarly to how it will look in production, so that any operator logic can be reliably tested
See the below schema diagram to understand how these objects must be linked by their foreign keys
If you would like to do any testing outside of the subsequent unit tests, you should manually load these fixtures into your local Beagle database as the test DB will only be created at test runtime
3. Create a TestCase
Write a test case that loads these fixtures and calls the get_jobs() method of the Operator class
You can emulate this example here: ACCESS SNV operator test
Include the “fixtures” attribute of the test case to automatically load the fixtures
Include assert statements any key aspects of the inputs file that you feel should be validated up front (such as sample IDs matching, or fields being present)
4. Write the Operator Code
Now you can write the code for the Operator by implementing the
get_jobs()
method of the Operator classYou can look at this example operator to start: ACCESS SNV operator
Notice how the relevant files are queried from the Beagle DB, and file paths are supplied as inputs to the pipeline
Make sure to register any input files in the Beagle DB using the
/v0/files
endpoint
5. Test the Operator
Test the operator by calling
/v0/run/operator/runs/
through the Django Swagger UI
6. Submit a Pull Request
Once you have completed testing your operator, submit a PR to the Beagle codebase
Last updated
Was this helpful?