Skip to content

Commit

Permalink
Merge pull request #73 from keboola/odin-AIS-35-d
Browse files Browse the repository at this point in the history
Modernize installation a bit
  • Loading branch information
odinuv authored May 22, 2023
2 parents 363ad2c + c161698 commit c6e3512
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 62 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea/
.git/
.env*
docker-compose.yml
Dockerfile
README.md
8 changes: 4 additions & 4 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
run: docker login --username "$DOCKERHUB_USER" --password "$DOCKERHUB_TOKEN"

- name: Build image
run: docker build -t $APP_IMAGE .
run: docker-compose build ci

- name: Check image
run: docker-compose run --rm sapi-python-client -m flake8
run: docker-compose run --rm ci -m flake8

- name: Set image tag
id: tag
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:

- name: Run Tests
run: |
docker-compose run --rm -e KBC_TEST_TOKEN=$KBC_TEST_TOKEN -e KBC_TEST_API_URL=$KBC_TEST_API_URL -e SKIP_ABS_TESTS=1 sapi-python-client -m unittest --verbose
docker-compose run --rm -e KBC_TEST_TOKEN=$KBC_TEST_TOKEN -e KBC_TEST_API_URL=$KBC_TEST_API_URL -e SKIP_ABS_TESTS=1 ci -m unittest --verbose
tests_azure:
name: Run tests (Azure)
Expand All @@ -84,7 +84,7 @@ jobs:

- name: Run Tests
run: |
docker-compose run --rm -e KBC_TEST_TOKEN=$KBC_AZ_TEST_TOKEN -e KBC_TEST_API_URL=$KBC_AZ_TEST_API_URL -e SKIP_ABS_TESTS=0 sapi-python-client -m unittest --verbose
docker-compose run --rm -e KBC_TEST_TOKEN=$KBC_AZ_TEST_TOKEN -e KBC_TEST_API_URL=$KBC_AZ_TEST_API_URL -e SKIP_ABS_TESTS=1 ci -m unittest --verbose
deploy_to_pypi:
needs:
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM python:3.11

WORKDIR /code
COPY . /code/
RUN /usr/local/bin/python -m pip install --upgrade pip
RUN pip3 install --no-cache-dir flake8 responses typing_extensions
RUN python setup.py install
RUN python -m pip install --upgrade pip
RUN pip install --no-cache-dir flake8
RUN pip install --no-cache-dir .
ENTRYPOINT ["python"]
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ for working with buckets, tables and workspaces are covered.

## Install

`$ pip3 install git+https://github.com/keboola/sapi-python-client.git`
```bash
pip install kbcstorage
```

or

```bash
$ git clone https://github.com/keboola/sapi-python-client.git && cd sapi-python-client
$ python setup.py install
pip install git+https://github.com/keboola/sapi-python-client.git
```

## Client Class Usage
```
```python
from kbcstorage.client import Client

client = Client('https://connection.keboola.com', 'your-token')
Expand All @@ -39,7 +40,7 @@ client.tables.detail('in.c-demo.some-table')
```

## Endpoint Classes Usage
```
```python
from kbcstorage.tables import Tables
from kbcstorage.buckets import Buckets

Expand All @@ -64,24 +65,24 @@ tables.detail('in.c-demo.some-table')
```

## Tests

```bash
$ git clone https://github.com/keboola/sapi-python-client.git && cd sapi-python-client
$ python setup.py test
```

or
Create `.env` file according to the `.env.template` file and run the tests with:

```bash
$ docker-compose run --rm -e KBC_TEST_TOKEN -e KBC_TEST_API_URL sapi-python-client -m unittest discover
```

## Contribution Guide
The client is far from supporting the entire API, all contributions are very welcome. New API endpoints should
be implemeneted in their own class extending `Endpoint`. Naming conventions should follow existing naming conventions
or those of the [API](http://docs.keboola.apiary.io/#). If the method contains some processing of the request or response, consult the corresponing [PHP implementation](https://github.com/keboola/storage-api-php-client) for reference. New code should be covered by tests.

Note that if you submit a PR from your own forked repository, the automated functional tests will fail. This is limitation of [Travis](https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions). Either run the tests locally (set `KBC_TEST_TOKEN` (your token to test project) and `KBC_TEST_API_URL` (https://connection.keboola.com) variables) or ask for access. In case, you need a project for local testing, feel free to [ask for one](https://developers.keboola.com/#development-project).
be implemented in their own class extending `Endpoint`. Naming conventions should follow existing naming conventions
or those of the [API](http://docs.keboola.apiary.io/#). If the method contains some processing of the request or
response, consult the corresponding [PHP implementation](https://github.com/keboola/storage-api-php-client) for
reference. New code should be covered by tests.

Note that if you submit a PR from your own forked repository, the automated functional tests will fail.
This is expected for security reasons, please do send the PR anyway.
Either run the tests locally (set `KBC_TEST_TOKEN` (your token to test project) and
`KBC_TEST_API_URL` (https://connection.keboola.com) variables) or ask for access. In case, you need a
project for local testing, feel free to [ask for one](https://developers.keboola.com/#development-project).

The recommended workflow for making a pull request is:

Expand Down
13 changes: 10 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
version: '2'
version: '3'
services:
sapi-python-client:
ci: &ci
build: .
image: sapi-python-client
environment:
- KBC_TEST_TOKEN
- KBC_TEST_API_URL
- SKIP_ABS_TESTS

dev:
<<: *ci
tty: true
stdin_open: true
command: bash
volumes:
- ./:/code/
- .:/code
7 changes: 0 additions & 7 deletions kbcstorage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
from pkg_resources import get_distribution, DistributionNotFound
try:
release = get_distribution('kbcstorage').version
__version__ = '.'.join(release.split('.')[:2])
except DistributionNotFound:
# package is not installed
pass
30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "kbcstorage"
authors = [
{name = "Keboola", email = "[email protected]"},
]
description = "Client for Keboola Storage API"
readme = "README.md"
requires-python = ">=3.7"
keywords = ["keboola", "storage"]
license = {file = "LICENSE"}
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 5 - Production/Stable",
]
dependencies = [
"boto3",
"azure-storage-blob",
"urllib3<2.0.0", # Frozen until fixed: https://github.com/boto/botocore/issues/2926
# Dev dependencies
"requests",
"responses",
"python-dotenv",
]
dynamic = ["version"]
26 changes: 0 additions & 26 deletions setup.py

This file was deleted.

3 changes: 0 additions & 3 deletions tests/base_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ class BaseTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
env_path = os.path.dirname(os.path.abspath(__file__)) + '/../.env'
print(env_path)
load_dotenv(env_path)

required_envs = ['KBC_TEST_API_URL', 'KBC_TEST_TOKEN', 'SKIP_ABS_TESTS']
for env in required_envs:
if os.getenv(env) is None:
print(env + ' is not configured')
exit(1)

print('All required envs are configured')

0 comments on commit c6e3512

Please sign in to comment.