Directory should look like this:
edenai_apis/apis/<provider>
├── <provider>_api.py
├── config.py (optional)
├── info.json
├── __init__.py
└── outputs
└── <feature>
└── <subfeature>_output.json
folder should contain:
-
config.py
optional -
info.json
a json file wich indicate subfeatures infos for each features eg:{ "text": { "summarize": { "version": "v1.0" "constraints": { # this is optional "languages": [ 'en', 'fr', ... ] } } } }
-
the main file
<provider-name>_api.py
should contain a class with your provider name that will inherit fromProviderInterface
class. it will also inherit from other abstract classes representing each features You will define feature methods according to the features class abstractmethods. each feature method has to return a Dictionary: containing the original response of the provider and your standardized responseeg:
class AmazonApi( ProviderInterface, Image Ocr, ): def image__object_detection(file_name: str, file_content: io.BytesIO) -> Dict: """your code here""" return {"original_response": response, "standardized_response": standardized}
-
An output directory containing one directory by feature, each feature directory will contain output json files representing original response returned by provider for a subfeature
edenai_apis/features/<feature>
├── __init__.py
├── <feature>_class.py
└── <subfeature>
├── <subfeature>_args.py
├── <subfeature>_dataclass.py
└── <subfeature>_response.json
- <feature>_class.py abstract class for method
- <subfeature>_args.py to generate arguments for tests
- <subfeature>_dataclass.py class for output
- <subfeature>_response.json: validated standardized response to compare with your own standarization
Tests should be run at the root of your project
-
Generate an ouptut from your feature method:
pytest -s edenai_apis/tests/outputs.py --provider <provider> --feature <feature> --subfeature <subfeature>
-
Run all projects tests:
pytest
-
Test classes only (without api call)
pytest edenai_apis/tests/test_classes.py
-
Test one provider with all subfeatures (example with microsoft)
pytest -m microsoft
-
Test all provider with one subfeature (example with invoice_parser)
pytest -m invoice_parser
-
Test with "and" or "or"
pytest -m "microsoft and invoice_parser" pytest -m "resume_parser or invoice_parser"
Usefull options
-s
: show output (print)-k test_method
: execute only test_method-n auto
: execute test in parallel-x
: stop at first fail