Creating a new SrcClass¶
Writing the Class¶
The easiest way to create a new SrcClass is by modifying an existing one to suit your needs.
If there is already a source that has the same or similar format as the one you are trying to add,
you can start with that. This will mean that you have a good starting point for
the table() method, which is the most complex part of each srcClass. SrcClasses
can be found in the src/code/srcClass/ directory, and that is also where new ones should go.
The __init__() Method¶
To begin, you will need to modify the __init__() method to initialize some attributes
that describe metadata about the source, making sure to call __init__() of the superclass:
SrcClass
Other Methods¶
You will then need to override or modify the other methods of SrcClass if the existing ones do not work for your new source. The most important methods are:
table
get_remote_url
get_source_version
get_aliases
Most of the time the defaults can be used for the other methods of the SrcClass subclass.
Testing and Running the Class¶
If you want to run the code using docker (the official method), you can build a local docker image that includes your code:
docker build path/to/KN_Builder/src/ -t knoweng/kn_builder:latest
If you do so, remember to remove the image before trying to run the official release again.
You can then run the pipeline as normal, making sure to specify your source in the arguments:
cd path/to/Knownet_Pipeline_Tools/
make SOURCES=<source>