# Car Connector Framework
## Develop a connector
Use connectors/reference_connector from [cp4s-car-connectors](https://github.com/IBM/cp4s-car-connectors) project as an example of how this framework is to be used.
A CAR connector project will need to extend the framework classes: [BaseFullImport](https://github.com/IBM/cp4s-car-connector-framework/blob/develop/car_framework/full_import.py), [BaseIncrementalImport](https://github.com/IBM/cp4s-car-connector-framework/blob/develop/car_framework/inc_import.py), [BaseApp](https://github.com/IBM/cp4s-car-connector-framework/blob/develop/car_framework/app.py), [BaseAssetServer](https://github.com/IBM/cp4s-car-connector-framework/blob/develop/car_framework/server_access.py) and [BaseDataHandler](https://github.com/IBM/cp4s-car-connector-framework/blob/develop/car_framework/data_handler.py), and implement abstract methods of those classes.
Things to note:
* All communications with CAR digestion microservice are managed by the framework. Connector code normally does not need to access CAR digestion microservice directly
* The framework is trying to make some intelligent choice for whether to run full vs incremental import. Normally, for performance reasons we would always prefer to run incremental import if one is possible. Some examples of when it is not possible are:
* The model states for generating delta are not available
* The model on the CAR side is empty
* The previous incremental import session failed and a new incremental import session can potentially create a gap in the model data
* Because of the above the the connector code should properly use (throw/raise) one of three following exceptions when detecting failures:
* [RecoverableFailure](https://github.com/IBM/cp4s-car-connector-framework/blob/99554ac2cfa0732af090c46be9e356beb015934e/car_framework/util.py#L77) is to be used when the failure cannot potentially create a data gap and we can attempt an incremental import session when running next time. One example of a recoverable failure is a connectivity problem.
* [UnrecoverableFailure](https://github.com/IBM/cp4s-car-connector-framework/blob/99554ac2cfa0732af090c46be9e356beb015934e/car_framework/util.py#L81) is to be used when the failure can potentially create a data gap and we must run full import session to recover.
* [DatasourceFailure](https://github.com/IBM/cp4s-car-connector-framework/blob/99554ac2cfa0732af090c46be9e356beb015934e/car_framework/util.py#L92) is to be used when there is datasource API issues.
RecoverableFailure and UnrecoverableFailure are mostly handled in the framework. DatasourceFailure is to be used in the connector code with [a corresponding error code](https://github.com/IBM/cp4s-car-connector-framework/blob/99554ac2cfa0732af090c46be9e356beb015934e/car_framework/util.py#L35). Example: `return ErrorCode.TRANSMISSION_AUTH_CREDENTIALS.value`.
If none of the Failure classes is used, the framework will raise a [GENERAL_APPLICATION_FAILURE](https://github.com/IBM/cp4s-car-connector-framework/blob/99554ac2cfa0732af090c46be9e356beb015934e/car_framework/app.py#L106) (Unknown error) and print the error stack.
For more information use guides
* https://github.com/IBM/cp4s-car-connectors/blob/develop/README.md
* https://github.com/IBM/cp4s-car-connectors/blob/develop/guide-build-connectors.md
* https://github.com/IBM/cp4s-car-connectors/tree/develop/connectors/reference_connector
* https://github.com/IBM/cp4s-car-connectors/blob/develop/best-practices.md
## Test deploy
https://github.com/IBM/cp4s-car-connectors/blob/develop/deployment/README.md
## Publish
Use the guide from [PUBLISH.md](./PUBLISH.md)
Raw data
{
"_id": null,
"home_page": "https://github.com/IBM/cp4s-car-connector-framework",
"name": "car-connector-framework",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "IBM",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/4b/45/4138070fea2b4431b5d20b78c963d6d89802af076a6d310ff459e60567b6/car-connector-framework-4.0.2.tar.gz",
"platform": "Any",
"description": "# Car Connector Framework\n\n## Develop a connector\n\nUse connectors/reference_connector from [cp4s-car-connectors](https://github.com/IBM/cp4s-car-connectors) project as an example of how this framework is to be used.\n\nA CAR connector project will need to extend the framework classes: [BaseFullImport](https://github.com/IBM/cp4s-car-connector-framework/blob/develop/car_framework/full_import.py), [BaseIncrementalImport](https://github.com/IBM/cp4s-car-connector-framework/blob/develop/car_framework/inc_import.py), [BaseApp](https://github.com/IBM/cp4s-car-connector-framework/blob/develop/car_framework/app.py), [BaseAssetServer](https://github.com/IBM/cp4s-car-connector-framework/blob/develop/car_framework/server_access.py) and [BaseDataHandler](https://github.com/IBM/cp4s-car-connector-framework/blob/develop/car_framework/data_handler.py), and implement abstract methods of those classes.\n\nThings to note:\n\n* All communications with CAR digestion microservice are managed by the framework. Connector code normally does not need to access CAR digestion microservice directly\n\n* The framework is trying to make some intelligent choice for whether to run full vs incremental import. Normally, for performance reasons we would always prefer to run incremental import if one is possible. Some examples of when it is not possible are:\n * The model states for generating delta are not available\n * The model on the CAR side is empty\n * The previous incremental import session failed and a new incremental import session can potentially create a gap in the model data\n\n* Because of the above the the connector code should properly use (throw/raise) one of three following exceptions when detecting failures:\n * [RecoverableFailure](https://github.com/IBM/cp4s-car-connector-framework/blob/99554ac2cfa0732af090c46be9e356beb015934e/car_framework/util.py#L77) is to be used when the failure cannot potentially create a data gap and we can attempt an incremental import session when running next time. One example of a recoverable failure is a connectivity problem.\n * [UnrecoverableFailure](https://github.com/IBM/cp4s-car-connector-framework/blob/99554ac2cfa0732af090c46be9e356beb015934e/car_framework/util.py#L81) is to be used when the failure can potentially create a data gap and we must run full import session to recover.\n * [DatasourceFailure](https://github.com/IBM/cp4s-car-connector-framework/blob/99554ac2cfa0732af090c46be9e356beb015934e/car_framework/util.py#L92) is to be used when there is datasource API issues.\n\nRecoverableFailure and UnrecoverableFailure are mostly handled in the framework. DatasourceFailure is to be used in the connector code with [a corresponding error code](https://github.com/IBM/cp4s-car-connector-framework/blob/99554ac2cfa0732af090c46be9e356beb015934e/car_framework/util.py#L35). Example: `return ErrorCode.TRANSMISSION_AUTH_CREDENTIALS.value`. \nIf none of the Failure classes is used, the framework will raise a [GENERAL_APPLICATION_FAILURE](https://github.com/IBM/cp4s-car-connector-framework/blob/99554ac2cfa0732af090c46be9e356beb015934e/car_framework/app.py#L106) (Unknown error) and print the error stack. \n\nFor more information use guides\n* https://github.com/IBM/cp4s-car-connectors/blob/develop/README.md\n* https://github.com/IBM/cp4s-car-connectors/blob/develop/guide-build-connectors.md\n* https://github.com/IBM/cp4s-car-connectors/tree/develop/connectors/reference_connector\n* https://github.com/IBM/cp4s-car-connectors/blob/develop/best-practices.md\n\n\n## Test deploy\nhttps://github.com/IBM/cp4s-car-connectors/blob/develop/deployment/README.md\n\n\n## Publish\n\nUse the guide from [PUBLISH.md](./PUBLISH.md)\n\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "CAR service connector framework",
"version": "4.0.2",
"project_urls": {
"Homepage": "https://github.com/IBM/cp4s-car-connector-framework"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8b33d6fa3bd7b0a2ff7ff278e782903fb37bf14f697e2294eead912f46ad0065",
"md5": "a135a1bfe947ad460bd396f771854f5c",
"sha256": "adfbf6522c75e58d1a6ba8a51adacbd61ea0bffd898b40a86491bbaae2ca91d1"
},
"downloads": -1,
"filename": "car_connector_framework-4.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a135a1bfe947ad460bd396f771854f5c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 22337,
"upload_time": "2024-07-30T20:02:05",
"upload_time_iso_8601": "2024-07-30T20:02:05.900962Z",
"url": "https://files.pythonhosted.org/packages/8b/33/d6fa3bd7b0a2ff7ff278e782903fb37bf14f697e2294eead912f46ad0065/car_connector_framework-4.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4b454138070fea2b4431b5d20b78c963d6d89802af076a6d310ff459e60567b6",
"md5": "c19ed8db74d4b5517ad8ac9d7fd2b286",
"sha256": "2952a779c35a4c3b29a98b23e42d54e0e5c32ef1a05f24e465f3510306d21c1a"
},
"downloads": -1,
"filename": "car-connector-framework-4.0.2.tar.gz",
"has_sig": false,
"md5_digest": "c19ed8db74d4b5517ad8ac9d7fd2b286",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 18106,
"upload_time": "2024-07-30T20:02:08",
"upload_time_iso_8601": "2024-07-30T20:02:08.050964Z",
"url": "https://files.pythonhosted.org/packages/4b/45/4138070fea2b4431b5d20b78c963d6d89802af076a6d310ff459e60567b6/car-connector-framework-4.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-30 20:02:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "IBM",
"github_project": "cp4s-car-connector-framework",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "requests",
"specs": [
[
">=",
"2.24.0"
]
]
},
{
"name": "python-json-logger",
"specs": [
[
"==",
"2.0.7"
]
]
},
{
"name": "jschon",
"specs": [
[
"==",
"0.8.5"
]
]
},
{
"name": "jwcrypto",
"specs": [
[
">=",
"1.4.2"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"1.26.19"
]
]
}
],
"lcname": "car-connector-framework"
}