Contributing Adapters¶
If the primitives that you want to add are not compliant with our fit-produce schema you will probably need to either add an adapter or modify an existing one in order to add them.
Creating a new Adapter¶
If you want to create a new adapter, please follow these steps:
If it does not exist yet, create a new GitHub issue requesting the primitive that requires it. As indicated previously, provide as many details as possible about the new primitive, like links to the documentation, what it does and what it is useful for, as well as details about why you think a new adapter is needed and how it would work.
Indicate in the issue description or in a comment that you are available to apply the changes yourself.
Wait for the feedback from the maintainers, who will approve the issue and assign it to you, before proceeding to implement any changes. Be open to discuss with them about the need of adding this primitive, as maybe there are other primitive that offer the same functionality, and about whether the adapter will be needed or not, or what is should look like.
Once the issue has been approved and assigned to you, implement the necessary changes in your own fork of the project. Please implement them in a branch named after the issue number and title, as this makes keeping track of the history of the project easier in the long run.
Create an adapter python module and add it to the
mlprimitives/adapters/
directory. The name of the module should be the name of the library that you want to create an adapter for. For example, if you want to add an adapter to add primitives from the library calledcool-ml
, the name of the module should bemlprimitives/adapters/cool_ml.py
. If the module already exists because there is another adapter for the same library, create the new adapter within the same module.Inside the adapter module, try to name the class or function that you create as similar as possible to the classes that you are writing the adapter for. For example, the adapter class for the
keras.Sequential
class is calledmlprimitives.adapters.keras.Sequential
, while the adapter class for thefeaturetools.dfs
method is calledmlprimitives.adapters.featuretools.DFS
.As usual, when writing python code, make sure to follow a coding style consistent with the rest of the library, and to follow all the guidelines form the Contributing Guidelines section.
Do not forget to properly document your code and cover it with proper unit testing!
Create at least on JSON annotation that uses your adapter. When doing so, make sure to follow the corresponding conventions:
The name of the file should correspond to the fully qualified name of the class or function that you are integrating ignoring the fact that you are using an adapter. For example, if you are adding the primitive
CoolPrimitive
from the modulecool_ml.module
by using themlprimitives/adapters/cool_ml.CoolML
adapter, the name of the file should becool_ml.module.CoolPrimitive.json
.Inside the JSON annotation, the
primitive
entry should have the fully qualified name of your adapter class, and thefixed
hyperparameters should contain all the details that your adapter needs to know how to integrate the third party primitive.Add proper description of what the primitive does in the corresponding entry, as well as a link to its documentation. If there is no documentation available, put the link to its source code. And don’t forget to add you name and e-mail address to the
contributors
list!Add a pipeline annotation that uses your primitive inside the pipelines folder, named exactly like your primitive, and test it with the command
mlprimitives test mlprimitives/pipelines/your.pipeline.json
. If adding a pipeline is not possible for any reason, please inform the maintainers, as this probably means that a new dataset needs to be added.
Review your changes and make sure that everything continues to work properly by executing the
make test-all
command.Push all your changes to GitHub and open a Pull Request, indicating in the description which issue you are resolving and what the changes consist of.
Modifying an existing Adapter¶
If an adapter for the library already exists but it does not properly cover one of the primitives that you want to integrate, you might find that modifying the existing adapter adds this coverage.
In this case, if you are sure that these modifications will not break previous functionality, and the existing adapter can be safely modified, do the following steps:
If it does not exist yet, create a new GitHub issue requesting the primitive that requires it. As indicated previously, provide as many details as possible about the new primitive, like links to the documentation, what it does and what it is useful for, as well as details about why you think the current adapter needs to be modified and how.
Indicate in the issue description or in a comment that you are available to apply the changes yourself.
Wait for the feedback from the maintainers, who will approve the issue and assign it to you, before proceeding to implement any changes. Be open to discuss with them about the need of adding this primitive, as maybe there are other primitive that offer the same functionality, and about whether the adapter can be modified or a new one created.
Once the issue has been approved and assigned to you, implement the necessary changes in your own fork of the project. Please implement them in a branch named after the issue number and title, as this makes keeping track of the history of the project easier in the long run.
Do the necessary modifications in the existing adapter.
As usual, when writing python code, make sure to follow a coding style consistent with the rest of the library, and to follow all the guidelines form the Contributing Guidelines section.
Do not forget to properly document your code and cover it with proper unit testing!
Create at least one new JSON annotation that uses the adapter. When doing so, make sure to follow the corresponding conventions:
The name of the file should correspond to the fully qualified name of the class or function that you are integrating ignoring the fact that you are using an adapter. For example, if you are adding the primitive
CoolPrimitive
from the modulecool_ml.module
by using themlprimitives/adapters/cool_ml.CoolML
adapter, the name of the file should becool_ml.module.CoolPrimitive.json
.Inside the JSON annotation, the
primitive
entry should have the fully qualified name of your adapter class, and thefixed
hyperparameters should contain all the details that your adapter needs to know how to integrate the third party primitive.Add proper description of what the primitive does in the corresponding entry, as well as a link to its documentation. If there is no documentation available, put the link to its source code. And don’t forget to add you name and e-mail address to the
contributors
list!Add a pipeline annotation that uses your primitive inside the pipelines folder, named exactly like your primitive, and test it with the command
mlprimitives test mlprimitives/pipelines/your.pipeline.json
. If adding a pipeline is not possible for any reason, please inform the maintainers, as this probably means that a new dataset needs to be added.Make sure that all the primitives that existed before that use the same adapter still work by testing their corresponding pipelines with the command above.
Review your changes and make sure that everything continues to work properly by executing the
make test-all
command.Push all your changes to GitHub and open a Pull Request, indicating in the description which issue you are resolving and what the changes consist of.