Skip to content

Commit c6e3512

Browse files
authored
Merge pull request #73 from keboola/odin-AIS-35-d
Modernize installation a bit
2 parents 363ad2c + c161698 commit c6e3512

File tree

9 files changed

+70
-62
lines changed

9 files changed

+70
-62
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.idea/
2+
.git/
3+
.env*
4+
docker-compose.yml
5+
Dockerfile
6+
README.md

.github/workflows/push.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ jobs:
3333
run: docker login --username "$DOCKERHUB_USER" --password "$DOCKERHUB_TOKEN"
3434

3535
- name: Build image
36-
run: docker build -t $APP_IMAGE .
36+
run: docker-compose build ci
3737

3838
- name: Check image
39-
run: docker-compose run --rm sapi-python-client -m flake8
39+
run: docker-compose run --rm ci -m flake8
4040

4141
- name: Set image tag
4242
id: tag
@@ -67,7 +67,7 @@ jobs:
6767

6868
- name: Run Tests
6969
run: |
70-
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
70+
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
7171
7272
tests_azure:
7373
name: Run tests (Azure)
@@ -84,7 +84,7 @@ jobs:
8484

8585
- name: Run Tests
8686
run: |
87-
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
87+
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
8888
8989
deploy_to_pypi:
9090
needs:

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM python:3.11
22

33
WORKDIR /code
44
COPY . /code/
5-
RUN /usr/local/bin/python -m pip install --upgrade pip
6-
RUN pip3 install --no-cache-dir flake8 responses typing_extensions
7-
RUN python setup.py install
5+
RUN python -m pip install --upgrade pip
6+
RUN pip install --no-cache-dir flake8
7+
RUN pip install --no-cache-dir .
88
ENTRYPOINT ["python"]

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ for working with buckets, tables and workspaces are covered.
66

77
## Install
88

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

1113
or
1214

1315
```bash
14-
$ git clone https://github.com/keboola/sapi-python-client.git && cd sapi-python-client
15-
$ python setup.py install
16+
pip install git+https://github.com/keboola/sapi-python-client.git
1617
```
1718

1819
## Client Class Usage
19-
```
20+
```python
2021
from kbcstorage.client import Client
2122

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

4142
## Endpoint Classes Usage
42-
```
43+
```python
4344
from kbcstorage.tables import Tables
4445
from kbcstorage.buckets import Buckets
4546

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

6667
## Tests
67-
68-
```bash
69-
$ git clone https://github.com/keboola/sapi-python-client.git && cd sapi-python-client
70-
$ python setup.py test
71-
```
72-
73-
or
68+
Create `.env` file according to the `.env.template` file and run the tests with:
7469

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

7974
## Contribution Guide
8075
The client is far from supporting the entire API, all contributions are very welcome. New API endpoints should
81-
be implemeneted in their own class extending `Endpoint`. Naming conventions should follow existing naming conventions
82-
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.
83-
84-
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).
76+
be implemented in their own class extending `Endpoint`. Naming conventions should follow existing naming conventions
77+
or those of the [API](http://docs.keboola.apiary.io/#). If the method contains some processing of the request or
78+
response, consult the corresponding [PHP implementation](https://github.com/keboola/storage-api-php-client) for
79+
reference. New code should be covered by tests.
80+
81+
Note that if you submit a PR from your own forked repository, the automated functional tests will fail.
82+
This is expected for security reasons, please do send the PR anyway.
83+
Either run the tests locally (set `KBC_TEST_TOKEN` (your token to test project) and
84+
`KBC_TEST_API_URL` (https://connection.keboola.com) variables) or ask for access. In case, you need a
85+
project for local testing, feel free to [ask for one](https://developers.keboola.com/#development-project).
8586

8687
The recommended workflow for making a pull request is:
8788

docker-compose.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
version: '2'
1+
version: '3'
22
services:
3-
sapi-python-client:
3+
ci: &ci
44
build: .
55
image: sapi-python-client
6+
environment:
7+
- KBC_TEST_TOKEN
8+
- KBC_TEST_API_URL
9+
- SKIP_ABS_TESTS
10+
11+
dev:
12+
<<: *ci
613
tty: true
714
stdin_open: true
815
command: bash
916
volumes:
10-
- ./:/code/
17+
- .:/code

kbcstorage/__init__.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +0,0 @@
1-
from pkg_resources import get_distribution, DistributionNotFound
2-
try:
3-
release = get_distribution('kbcstorage').version
4-
__version__ = '.'.join(release.split('.')[:2])
5-
except DistributionNotFound:
6-
# package is not installed
7-
pass

pyproject.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[build-system]
2+
requires = ["setuptools", "setuptools-scm"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "kbcstorage"
7+
authors = [
8+
{name = "Keboola", email = "[email protected]"},
9+
]
10+
description = "Client for Keboola Storage API"
11+
readme = "README.md"
12+
requires-python = ">=3.7"
13+
keywords = ["keboola", "storage"]
14+
license = {file = "LICENSE"}
15+
classifiers = [
16+
"Programming Language :: Python :: 3",
17+
"License :: OSI Approved :: MIT License",
18+
"Operating System :: OS Independent",
19+
"Development Status :: 5 - Production/Stable",
20+
]
21+
dependencies = [
22+
"boto3",
23+
"azure-storage-blob",
24+
"urllib3<2.0.0", # Frozen until fixed: https://github.com/boto/botocore/issues/2926
25+
# Dev dependencies
26+
"requests",
27+
"responses",
28+
"python-dotenv",
29+
]
30+
dynamic = ["version"]

setup.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/base_test_case.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ class BaseTestCase(unittest.TestCase):
88
@classmethod
99
def setUpClass(cls) -> None:
1010
env_path = os.path.dirname(os.path.abspath(__file__)) + '/../.env'
11-
print(env_path)
1211
load_dotenv(env_path)
1312

1413
required_envs = ['KBC_TEST_API_URL', 'KBC_TEST_TOKEN', 'SKIP_ABS_TESTS']
1514
for env in required_envs:
1615
if os.getenv(env) is None:
1716
print(env + ' is not configured')
1817
exit(1)
19-
20-
print('All required envs are configured')

0 commit comments

Comments
 (0)