-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:ToucanToco/toucan-connectors
- Loading branch information
Showing
66 changed files
with
1,774 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
.ipynb_checkpoints/Method forwarding in connectors-checkpoint.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 38, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from pydantic import BaseModel\n", | ||
"from typing import Callable" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 39, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"class DummyDataSource(BaseModel):\n", | ||
" table: str\n", | ||
"\n", | ||
"class DummyConnector(BaseModel):\n", | ||
" host: str\n", | ||
" secrets_id: str\n", | ||
" \n", | ||
" get_secrets: Callable[[str], dict]\n", | ||
" \n", | ||
" def get_df(self, data_source: DummyDataSource):\n", | ||
" print('get_df for table', data_source.table)\n", | ||
" print('with secrets: ', self.get_secrets(self.secrets_id))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 40, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"get_df for table plop\n", | ||
"with secrets: {'token': '1234567890'}\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"def get_dummy_secrets(secrets_id):\n", | ||
" if secrets_id == 'aaa':\n", | ||
" return {'token': '1234567890'}\n", | ||
" elif secrets_id == 'bbb':\n", | ||
" return {'token': 'azertyuiop'}\n", | ||
"\n", | ||
"conn_config = {'host': '0.2.3.4', 'secrets_id': 'aaa'}\n", | ||
"conn = DummyConnector(get_secrets=get_dummy_secrets, **conn_config)\n", | ||
"ds = DummyDataSource(table='plop')\n", | ||
"\n", | ||
"conn.get_df(ds)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 41, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"{'title': 'DummyConnector',\n", | ||
" 'type': 'object',\n", | ||
" 'properties': {'host': {'title': 'Host', 'type': 'string'},\n", | ||
" 'secrets_id': {'title': 'Secrets Id', 'type': 'string'}},\n", | ||
" 'required': ['host', 'secrets_id']}" | ||
] | ||
}, | ||
"execution_count": 41, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"DummyConnector.schema()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.2.0 | ||
hooks: | ||
- id: check-yaml | ||
- id: check-toml | ||
- id: check-json | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
|
||
- repo: http://gitlab.com/pycqa/flake8 | ||
rev: 3.8.3 | ||
hooks: | ||
- id: flake8 | ||
name: Lint Python files using flake8 | ||
|
||
- repo: https://github.com/timothycrosley/isort | ||
rev: 5.5.4 | ||
hooks: | ||
- id: isort | ||
name: Sort Python imports | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 20.8b1 | ||
hooks: | ||
- id: black | ||
name: Reformat Python files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 38, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from pydantic import BaseModel\n", | ||
"from typing import Callable" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 39, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"class DummyDataSource(BaseModel):\n", | ||
" table: str\n", | ||
"\n", | ||
"class DummyConnector(BaseModel):\n", | ||
" host: str\n", | ||
" secrets_id: str\n", | ||
" \n", | ||
" get_secrets: Callable[[str], dict]\n", | ||
" \n", | ||
" def get_df(self, data_source: DummyDataSource):\n", | ||
" print('get_df for table', data_source.table)\n", | ||
" print('with secrets: ', self.get_secrets(self.secrets_id))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 42, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"get_df for table plop\n", | ||
"with secrets: {'token': '1234567890'}\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"def get_dummy_secrets(secrets_id):\n", | ||
" if secrets_id == 'aaa':\n", | ||
" return {'token': '1234567890'}\n", | ||
" elif secrets_id == 'bbb':\n", | ||
" return {'token': 'azertyuiop'}\n", | ||
"\n", | ||
"conn_config = {'host': '0.2.3.4', 'secrets_id': 'aaa'}\n", | ||
"conn = DummyConnector(get_secrets=get_dummy_secrets, **conn_config)\n", | ||
"ds = DummyDataSource(table='plop')\n", | ||
"\n", | ||
"conn.get_df(ds)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 43, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"{'title': 'DummyConnector',\n", | ||
" 'type': 'object',\n", | ||
" 'properties': {'host': {'title': 'Host', 'type': 'string'},\n", | ||
" 'secrets_id': {'title': 'Secrets Id', 'type': 'string'}},\n", | ||
" 'required': ['host', 'secrets_id']}" | ||
] | ||
}, | ||
"execution_count": 43, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"DummyConnector.schema()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.