Repository URL to install this package:
|
Version:
0.9.1 ▾
|
namara-python
/
METADATA
|
|---|
Metadata-Version: 2.1
Name: namara-python
Version: 0.9.1
Summary: A simple interface for working with Namara in Python
Home-page: https://thinkdataworks.com
Author: Thinkdata Works
Author-email: contact@thinkdataworks.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: protobuf (==3.11.3)
Requires-Dist: requests (==2.23.0)
Requires-Dist: python-dotenv (==0.12.0)
Requires-Dist: pandas (==1.0.1)
Requires-Dist: modin (==0.7.2)
Requires-Dist: memory-profiler (==0.57.0)
# namara-python
Python SDK for Namara API and namara-pandas
## Installation
You need Python 3.7 or above and the package manager [pip](https://pip.pypa.io/en/stable/) to install dependencies.
```bash
pip3 install -r requirements.txt
```
## Authorization
Can read API key from environment variables or directly passed into Client.
The Namara API urls are also read from environement variables
```syntax=ruby
export NAMARA_API_KEY=my_namara_api_key
export NAMARA_API_URL=https://api.ee-dev.namara.io
export NAMARA_AUTH_URL=https://account.ee-dev.namara.io
```
In Python
```syntax=ruby
from namara_python.client import Client
client = Client()
```
*OR*
Pass them in directly
```
from namara_python.client import Client
client = Client(
api_key='my_namara_api_key',
auth_url='https://account.ee-dev.namara.io',
api_url='https://api.ee-dev.namara.io'
)
```
The `client` object is now ready to make requests to Namara API
## Environment variables
You can create a `.env` file to manage environment variables more easily, namara-python will read those.
in `.env`
```syntax=ruby
export NAMARA_API_KEY=my_namara_api_key
export NAMARA_API_URL=https://api.ee-dev.namara.io
export NAMARA_AUTH_URL=https://account.ee-dev.namara.io
```
## Query
You can pass the query statement directly
```
from namara_python.client import Client
c = Client(
api_key='my_namara_api_key',
auth_url='https://account.ee-dev.namara.io',
api_url='https://api.ee-dev.namara.io'
)
q = c.query_client()
res = q.query(statement='SELECT * FROM f78871ca-71f9-4071-859c-7d6ba414972e AS ACM')
print(res)
```
The `Query` object is now ready to make NiQL queries directly to Namara Query API
## Development
### Running tests
`make test`
You can run a specific test by marking it in the test file, above the function:
```syntax=ruby
@pytest.mark.only # <- add this
def only_test_to_run():
...
```
And then run
```
make test_only
```
### Static analysis
This project uses Pythons type annotations for some static analysis for types.
Install mypy
```syntax=ruby
pip install mypy
```
To do type checking
```syntax=ruby
mypy --ignore-missing-imports .
```
We skip import checks just becuase mypy doesn't quite work as you would expect for imports, especially third party packages
## Pandas extension
Look here: https://github.com/thinkdata-works/namara-python/tree/develop/namara_pandas