Create a new format
Technical Requirements
- Clone the Github repository SEKOIA-IO/intake-formats
Create a module
If the module that will contain your format doesn't exist, you will need to create it.
To create a new module, follow these steps:
- Execute the following command:
> cd ~/dev/intake-formats/utils
> poetry run python3 generate.py new-module
-
Complete the form with the name of the module, its description and its destination directory. A new directory, with the name of the module, will appear at the root of your workspace.
-
In the
_meta
directory, add a logo to illustrate your module with the following criteria: -
The logo must be a PNG image
- The logo must be named
logo.png
- The background must be transparent
- The image must be squared, ie the width is equal to the height
- The weight of the logo must be lesser than 50kb
Create a format
To create a new format, follow these steps:
- Execute the following command:
> cd ~/dev/intake-formats/utils
> poetry run python3 generate.py new-format <module_directory>
-
Complete the form with the name of the format, its slug and a description. Your new format will appear, as a directory, under its module directory.
-
Open your format’s manifest (
_meta/manifest.yml
) and provide some data sources with a description for each one -
In the
_meta
directory, add a logo to illustrate your format with the following criteria: -
The logo must be a PNG image
- The logo must be named
logo.png
- The background must be transparent
- The image must be squared, ie the width is equal to the height
- The weight of the logo must be lesser than 50kb.
Create the parser
To create the parser, follow these steps:
-
In the format directory, go to the
ingest
folder and editparser.yml
-
Follow this guide to develop the parser
Note that the parser must generate structured events that respect the taxonomy of the format
Create a test
To create the test file, follow these steps:
- From a sample event, use create_test.py to create a new test file
> cd ~/dev/intake-formats/utils
> poetry run python3 create_test.py ~/dev/intake-formats/<module>/<format>/tests/test_my_event.json <event>
> cat /tmp/raw_event.txt | poetry run python3 create_test.py ~/dev/intake-formats/<module>/<format>/tests/test_my_second_event.json -
- Complete the test file with expected fields
Run tests
Tests are run from the intake-formats/utils
directory.
> cd ~/dev/intake-formats/utils
> poetry run pytest test_formats.py -vv # run tests for all parsers
> poetry run pytest test_formats.py -vv --changes # run tests only for updated parsers
> poetry run pytest test_formats.py --module='module-name' -vv # run tests for a specific module
> poetry run pytest test_formats.py --format='format-name' -vv # run tests for a specific format
> poetry run pytest test_formats.py --format='format-name' --fix-expectations # fix test expectations
Write smart descriptions
The structured events, generated by the parser can be hardly readable for a human. The smart descriptions will define how to describe the events and which important information must be displayed in the description to ease the decision-making process.
To write smart descriptions, follow these steps:
-
In the format directory, go to the
_meta
folder and editsmart-descriptions.json
-
Follow this guide to write smart descriptions for your format