Skip to content

Release/v2.0.0 #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 136 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
154c8c0
Add deprecation warnings for `space_id`
PabloPardoGarcia Sep 18, 2024
e19bc8a
Create APIClient abstract class
PabloPardoGarcia Sep 18, 2024
e53aafa
Create APIClient abstract class
PabloPardoGarcia Sep 18, 2024
4f50993
Add PipelineDataSink and PipelineDataSource clients
PabloPardoGarcia Sep 18, 2024
b3b9c5f
Add deprecation warnings to PipelineClient
PabloPardoGarcia Sep 18, 2024
bb58e1f
Remove client from GlassFlowConfig
PabloPardoGarcia Sep 18, 2024
9e51392
include PipelineDataSource and PipelineDataSink
PabloPardoGarcia Sep 18, 2024
588150b
add Personal Access Token on glassflow client
PabloPardoGarcia Sep 18, 2024
aadcf42
chore: correct typo
PabloPardoGarcia Sep 18, 2024
054fd5e
import errors at top level
PabloPardoGarcia Sep 18, 2024
1680c03
chore: code format
PabloPardoGarcia Sep 18, 2024
4ac0942
update documentation
PabloPardoGarcia Sep 18, 2024
0586f84
add docstrings to errors
PabloPardoGarcia Sep 18, 2024
ca2024a
add tests for PipelineDataSink and PipelineDataSource and use staging…
PabloPardoGarcia Sep 18, 2024
b0a8671
revert accidental title delete
PabloPardoGarcia Sep 18, 2024
af99445
remove duplicated glassflow config attribute
PabloPardoGarcia Sep 18, 2024
257d15f
make gf config class variable and simplify fixtures
PabloPardoGarcia Sep 18, 2024
77fcdd4
add test to check source uses staging api
PabloPardoGarcia Sep 18, 2024
32e74ed
:chore: remove unused import
PabloPardoGarcia Sep 18, 2024
c4f39c8
remove deprecated code and move APIClient to client.py
PabloPardoGarcia Sep 19, 2024
805fc7e
Merge pull request #22 from glassflow/pablo/dev-157-add-personal-mana…
PabloPardoGarcia Sep 19, 2024
ea821f8
move APIClient to api_client.py
PabloPardoGarcia Sep 19, 2024
7acaa9d
add unknown content type error
PabloPardoGarcia Sep 19, 2024
66b90f4
move APIClient to api_client.py
PabloPardoGarcia Sep 19, 2024
5068e93
create base request and response data models
PabloPardoGarcia Sep 19, 2024
0c04ae4
move request logic to APIClient
PabloPardoGarcia Sep 19, 2024
d494fe1
remove unused kwargs
PabloPardoGarcia Sep 20, 2024
ab82c24
:chore: format code
PabloPardoGarcia Sep 20, 2024
172eee9
Merge pull request #23 from glassflow/pablo/add-request-method-in-api…
PabloPardoGarcia Sep 20, 2024
30ad343
create new abstractions from BaseRequest
PabloPardoGarcia Sep 20, 2024
4a8b8c4
not raise on 429 error code in APIClient
PabloPardoGarcia Sep 20, 2024
bbf4536
add unauthorised error
PabloPardoGarcia Sep 20, 2024
a5b105b
use APIClient request in validate_credentials method
PabloPardoGarcia Sep 20, 2024
19dcee9
add API data models
PabloPardoGarcia Sep 20, 2024
7d2a7b3
add get request and response models
PabloPardoGarcia Sep 20, 2024
d60c3b3
add Pipeline model and get_pipeline method
PabloPardoGarcia Sep 20, 2024
1e6bc40
catch 404 and 401 in PipelineDataClient
PabloPardoGarcia Sep 23, 2024
017baaf
Create BaseManagementRequest and organise base requests
PabloPardoGarcia Sep 23, 2024
e4344d8
Make APIClient inherit from ABC
PabloPardoGarcia Sep 23, 2024
c9be38e
Add create_pipeline method
PabloPardoGarcia Sep 23, 2024
6bb3f38
add unit tests
PabloPardoGarcia Sep 23, 2024
d863371
move fetch and create pipeline logic to Pipeline object
PabloPardoGarcia Sep 23, 2024
2f136bf
remove kw_only for compatibility with < py3.10
PabloPardoGarcia Sep 23, 2024
79f541a
add consume_failed tests and rename test files
PabloPardoGarcia Sep 23, 2024
3910490
add unittest create_pipeline
PabloPardoGarcia Sep 23, 2024
e38036d
add test coverage
PabloPardoGarcia Sep 23, 2024
2b6f4ee
add PAT to workflow envs
PabloPardoGarcia Sep 23, 2024
5b3128d
:chore: core format
PabloPardoGarcia Sep 23, 2024
9d12fb5
:chore: core format
PabloPardoGarcia Sep 23, 2024
92f1af0
:chore: core format
PabloPardoGarcia Sep 23, 2024
06f7e40
add unittest for pipeline creation with none existing transformation …
PabloPardoGarcia Sep 23, 2024
b3044fe
:chore: code format
PabloPardoGarcia Sep 23, 2024
61bdef4
unify unit and integration tests step
PabloPardoGarcia Sep 23, 2024
d09b7ad
Merge pull request #24 from glassflow/pablo/dev-158-add-get-method-to…
PabloPardoGarcia Sep 23, 2024
b0cb034
upload/download cov report and add dependency between tests and cover…
PabloPardoGarcia Sep 23, 2024
ab163a7
generate api classes
PabloPardoGarcia Sep 24, 2024
775ff3b
add Pipeline.delete method
PabloPardoGarcia Sep 24, 2024
2e95149
:chore: code formatting
PabloPardoGarcia Sep 24, 2024
4fc3331
simplify docs code
PabloPardoGarcia Sep 24, 2024
045a69b
Merge pull request #25 from glassflow/dev
PabloPardoGarcia Sep 24, 2024
edc31f9
add release/* branches to workflow
PabloPardoGarcia Sep 24, 2024
33f4173
bump glassflow to v2.0.0
PabloPardoGarcia Sep 24, 2024
b5ac021
Fix UnknownContent error when nothing to consume
PabloPardoGarcia Sep 25, 2024
545b9bb
add created_at attribute to pipeline
PabloPardoGarcia Sep 25, 2024
cb5fe5f
add CRUD tests
PabloPardoGarcia Sep 25, 2024
c6a825e
add SPACE_ID secret and remove unused secrets to workflow
PabloPardoGarcia Sep 25, 2024
a584e65
add get_source and get_sink methods to Pipeline
PabloPardoGarcia Sep 25, 2024
f739d4a
rename tests
PabloPardoGarcia Sep 25, 2024
5860635
add list_pipelines method
PabloPardoGarcia Sep 25, 2024
f5fd098
expose Pipeline constructor in top level
PabloPardoGarcia Sep 25, 2024
bfc7bd1
fix sink and source config type hint
PabloPardoGarcia Sep 25, 2024
03bcad8
update documentation
PabloPardoGarcia Sep 25, 2024
4403bc9
change version to 2.0.0rc
PabloPardoGarcia Sep 25, 2024
5ae41aa
:chore: format code
PabloPardoGarcia Sep 25, 2024
88dc0c0
bump version to deploy on test pypi
Sep 26, 2024
171f174
add space list and create operation
Sep 27, 2024
943455a
bump test deploy version
Sep 27, 2024
db34fa9
Merge pull request #27 from glassflow/space-management
ashish-bagri Sep 27, 2024
32582f2
create pipeline before testing get_pipeline
PabloPardoGarcia Sep 30, 2024
243ee13
add more unit tests
PabloPardoGarcia Sep 30, 2024
24b070c
fix env_vars type hint
PabloPardoGarcia Sep 30, 2024
c5e84bb
Merge branch 'release/v2.0.0' of github.com:glassflow/glassflow-pytho…
PabloPardoGarcia Sep 30, 2024
79e7bfb
:chore: format code
PabloPardoGarcia Sep 30, 2024
fb81582
fix response type hint
PabloPardoGarcia Sep 30, 2024
9cfa499
add delete method to Space
PabloPardoGarcia Sep 30, 2024
822bcda
create and delete space during IT
PabloPardoGarcia Sep 30, 2024
b054733
:chore: format code
PabloPardoGarcia Sep 30, 2024
c34ae85
add more unit tests on data client
PabloPardoGarcia Sep 30, 2024
2d3d7af
fixes DEV-196
PabloPardoGarcia Sep 30, 2024
656c0a6
add unittests for spaces
PabloPardoGarcia Sep 30, 2024
caa6c37
add integration test for spaces
PabloPardoGarcia Sep 30, 2024
13ed605
catch space client errors
PabloPardoGarcia Sep 30, 2024
0049f85
add more space integration tests
PabloPardoGarcia Sep 30, 2024
8e628d6
rename fixtures
PabloPardoGarcia Sep 30, 2024
936ceaa
:chore: format code
PabloPardoGarcia Sep 30, 2024
c6f0e15
add pipeline update method and tests
PabloPardoGarcia Sep 30, 2024
015897e
:chore: format file
PabloPardoGarcia Sep 30, 2024
bfd0cb1
fetch function source when pipeline.fetch
PabloPardoGarcia Sep 30, 2024
7014af7
create fixture request mocks
PabloPardoGarcia Sep 30, 2024
08332af
add get function source request
PabloPardoGarcia Sep 30, 2024
5bd1566
add get_logs method
PabloPardoGarcia Oct 1, 2024
31408e6
add dataclass_json decorator
PabloPardoGarcia Oct 1, 2024
5eac67d
use subclass enum
PabloPardoGarcia Oct 1, 2024
778188d
:chore: format code
PabloPardoGarcia Oct 1, 2024
536c42a
add tests for get logs
PabloPardoGarcia Oct 1, 2024
484374a
avoid using 3r party dependency
PabloPardoGarcia Oct 1, 2024
3d612fc
remove unused secret
PabloPardoGarcia Oct 1, 2024
348b51e
write coverage message not only on main
PabloPardoGarcia Oct 1, 2024
1f83061
:chore: format code
PabloPardoGarcia Oct 1, 2024
f97a302
download cov report to work dir
PabloPardoGarcia Oct 1, 2024
8290d54
bump rc version to 2.0.0rc3
PabloPardoGarcia Oct 1, 2024
ed5e872
do not hide cov comment
PabloPardoGarcia Oct 1, 2024
103b14d
skip covered files in report
PabloPardoGarcia Oct 1, 2024
4aa4468
bump rc version to 2.0.0rc4
PabloPardoGarcia Oct 1, 2024
6ef2256
add junitxml report to PR comment
PabloPardoGarcia Oct 1, 2024
c9ef76f
fix skip-covered configuration
PabloPardoGarcia Oct 1, 2024
60d98bb
remove `transformation_code` reference
PabloPardoGarcia Oct 1, 2024
d29ec90
bump rc version to 2.0.0rc5
PabloPardoGarcia Oct 1, 2024
5ec3164
:chore: format code [skip ci]
PabloPardoGarcia Oct 1, 2024
5606706
bump version to 2.0.2rc1
PabloPardoGarcia Oct 1, 2024
8194eae
add max tries to consume and get logs tests
PabloPardoGarcia Oct 1, 2024
a79dfcb
bump version to 2.0.0rc2
PabloPardoGarcia Oct 1, 2024
952b278
fix unset transformation_file on update
PabloPardoGarcia Oct 2, 2024
6ee1b19
bump rc version to 2.0.2rc3
PabloPardoGarcia Oct 2, 2024
089eae8
:chore: format code [skip ci]
PabloPardoGarcia Oct 2, 2024
3c07197
bump rc version to 2.0.2rc4
PabloPardoGarcia Oct 2, 2024
59dac26
update env vars from function patch endpoint and refactor to fit func…
PabloPardoGarcia Oct 2, 2024
23a140f
bump rc version to 2.0.2rc5
PabloPardoGarcia Oct 2, 2024
286572b
handle space is not empty error in space deletion
PabloPardoGarcia Oct 4, 2024
9001b66
add serialization_method arg to _request
PabloPardoGarcia Oct 4, 2024
4af7c56
fix update artifact and test state change
PabloPardoGarcia Oct 4, 2024
ad92af9
bump rc to 2.0.2rc6
PabloPardoGarcia Oct 4, 2024
10f64d5
update docs with pipeline and space management
PabloPardoGarcia Oct 8, 2024
0bfe27b
fix broken links
PabloPardoGarcia Oct 8, 2024
03b19e3
add new files to reference
PabloPardoGarcia Oct 8, 2024
5a16858
bump rc version to 2.0.2rc7
PabloPardoGarcia Oct 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 55 additions & 8 deletions .github/workflows/on_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on:
pull_request:
branches:
- main
- release/*

permissions:
contents: write
checks: write
pull-requests: write

jobs:
tests:
Expand All @@ -24,11 +30,17 @@ jobs:
- name: Install dependencies
run: pip install -e .[dev]

- name: Run Integration Tests
run: pytest tests/glassflow/integration_tests/
- name: Run Tests
run: pytest
env:
PIPELINE_ID: ${{ secrets.PIPELINE_ID }}
PIPELINE_ACCESS_TOKEN: ${{ secrets.PIPELINE_ACCESS_TOKEN }}
SPACE_ID: ${{ secrets.INTEGRATION_SPACE_ID }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.INTEGRATION_PERSONAL_ACCESS_TOKEN }}

- name: Upload coverage report
uses: actions/upload-artifact@master
with:
name: coverageReport
path: tests/reports/coverage.xml

checks:
name: Run code checks
Expand All @@ -48,8 +60,43 @@ jobs:
- name: Install dependencies
run: pip install -e .[dev]

- name: Run isort
run: isort .

- name: Run linter and code formatter
- name: Run ruff linter checks
run: ruff check .

- name: Run ruff formatting checks
run: ruff format --check .

coverage:
runs-on: ubuntu-latest
needs: [tests]
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo

- name: Download coverage report
uses: actions/download-artifact@master
with:
name: coverageReport
path: tests/reports/coverage.xml

- name: Pytest coverage comment
if: ${{ github.ref == 'refs/heads/main' }}
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
hide-comment: true
pytest-xml-coverage-path: ./tests/reports/coverage.xml

- name: Update Readme with Coverage Html
if: ${{ github.ref == 'refs/heads/main' }}
run: |
sed -i '/<!-- Pytest Coverage Comment:Begin -->/,/<!-- Pytest Coverage Comment:End -->/c\<!-- Pytest Coverage Comment:Begin -->\n\${{ steps.coverageComment.outputs.coverageHtml }}\n<!-- Pytest Coverage Comment:End -->' ./README.md

- name: Commit & Push changes to Readme
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions-js/push@master
with:
message: Update coverage on Readme
github_token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ site**
.pypirc
dist/
build
.env
.env
tests/reports
.coverage
162 changes: 147 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<img src="https://img.shields.io/badge/slack-join-community?logo=slack&amp;logoColor=white&amp;style=flat"
alt="Chat on Slack"></a>
<a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff" style="max-width:100%;"></a>
<!-- Pytest Coverage Comment:Begin -->
<!-- Pytest Coverage Comment:End -->


# GlassFlow Python SDK
Expand All @@ -22,11 +24,12 @@ You can install the GlassFlow Python SDK using pip:
pip install glassflow
```

## Available Operations
## Data Operations

* [publish](#publish) - Publish a new event into the pipeline
* [consume](#consume) - Consume the transformed event from the pipeline
* [consume failed](#consume-failed) - Consume the events that failed from the pipeline
* [validate credentials](#validate-credentials) - Validate pipeline credentials


## publish
Expand All @@ -36,12 +39,11 @@ Publish a new event into the pipeline
### Example Usage

```python
import glassflow
from glassflow import PipelineDataSource

client = glassflow.GlassFlowClient()
pipeline_client = client.pipeline_client(pipeline_id="<str value", pipeline_access_token="<str value>")
source = PipelineDataSource(pipeline_id="<str value", pipeline_access_token="<str token>")
data = {} # your json event
res = pipeline_client.publish(request_body=data)
res = source.publish(request_body=data)

if res.status_code == 200:
print("Published sucessfully")
Expand All @@ -55,33 +57,163 @@ Consume the transformed event from the pipeline
### Example Usage

```python
import glassflow
from glassflow import PipelineDataSink

client = glassflow.GlassFlowClient()
pipeline_client = client.pipeline_client(pipeline_id="<str value", pipeline_access_token="<str value>")
res = pipeline_client.consume()
sink = PipelineDataSink(pipeline_id="<str value", pipeline_access_token="<str value>")
res = sink.consume()

if res.status_code == 200:
print(res.body.event)
print(res.json())
```


## consume failed

If the transformation failed for any event, they are available in a failed queue. You can consume those events from the pipeline

### Example Usage

```python
import glassflow
from glassflow import PipelineDataSink

client = glassflow.GlassFlowClient()
pipeline_client = client.pipeline_client(pipeline_id="<str value", pipeline_access_token="<str value>")
res = pipeline_client.consume_failed()
sink = PipelineDataSink(pipeline_id="<str value", pipeline_access_token="<str value>")
res = sink.consume_failed()

if res.status_code == 200:
print(res.body.event)
print(res.json())
```


## validate credentials

Validate pipeline credentials (`pipeline_id` and `pipeline_access_token`) from source or sink

### Example Usage

```python
from glassflow import PipelineDataSource, errors

try:
source = PipelineDataSource(pipeline_id="<str value", pipeline_access_token="<str value>")
source.validate_credentials()
except errors.PipelineNotFoundError as e:
print("Pipeline ID does not exist!")
raise e
except errors.PipelineAccessTokenInvalidError as e:
print("Pipeline Access Token is invalid!")
raise e
```


## Pipeline Management

In order to manage your pipelines with this SDK, one needs to provide the `PERSONAL_ACCESS_TOKEN`
to the GlassFlow client.

```python
from glassflow import GlassFlowClient

client = GlassFlowClient(personal_access_token="<your personal access token>")
```

Now you can perform CRUD operations on your pipelines:

* [list_pipelines](#list_pipelines) - Returns the list of pipelines available
* [get_pipeline](#get_pipeline) - Returns a pipeline object from a given pipeline ID
* [create](#create) - Create a new pipeline
* [delete](#delete) - Delete an existing pipeline

## list_pipelines

Returns information about the available pipelines. It can be restricted to a
specific space by passing the `space_id`.

### Example Usage

```python
from glassflow import GlassFlowClient

client = GlassFlowClient(personal_access_token="<your access token>")
res = client.list_pipelines()
```

## get_pipeline

Gets information about a pipeline from a given pipeline ID. It returns a Pipeline object
which can be used manage the Pipeline.

### Example Usage

```python
from glassflow import GlassFlowClient

client = GlassFlowClient(personal_access_token="<your access token>")
pipeline = client.get_pipeline(pipeline_id="<your pipeline id>")

print("Name:", pipeline.name)
```

## create

The Pipeline object has a create method that creates a new GlassFlow pipeline.

### Example Usage

```python
from glassflow import Pipeline

pipeline = Pipeline(
name="<your pipeline name>",
transformation_file="path/to/transformation.py",
space_id="<your space id>",
personal_access_token="<your personal access token>"
).create()
```

In the next example we create a pipeline with Google PubSub source
and a webhook sink:

```python
from glassflow import Pipeline

pipeline = Pipeline(
name="<your pipeline name>",
transformation_file="path/to/transformation.py",
space_id="<your space id>",
personal_access_token="<your personal access token>",
source_kind="google_pubsub",
source_config={
"project_id": "<your gcp project id>",
"subscription_id": "<your subscription id>",
"credentials_json": "<your credentials json>"
},
sink_kind="webhook",
sink_config={
"url": "<webhook url>",
"method": "<GET | POST | PUT | PATCH | DELETE>",
"headers": [{"header1": "header1_value"}]
}
).create()
```

## delete

The Pipeline object has a delete method to delete a pipeline

### Example Usage

```python
from glassflow import Pipeline

pipeline = Pipeline(
name="<your pipeline name>",
transformation_file="path/to/transformation.py",
space_id="<your space id>",
personal_access_token="<your personal access token>"
).create()

pipeline.delete()
```

## Quickstart

Expand Down
8 changes: 5 additions & 3 deletions USAGE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
```python
import glassflow

client = glassflow.GlassFlowClient()
pipeline = client.pipeline_client(pipeline_id="<pipeline_id>", pipeline_access_token="<pipeline_token>")
source = glassflow.PipelineDataSource(pipeline_id="<pipeline_id>", pipeline_access_token="<pipeline_token>")
data = {
"name": "Hello World",
"id": 1
}
res = pipeline.publish(request_body=data)
source_res = source.publish(request_body=data)

sink = glassflow.PipelineDataSink(pipeline_id="<pipeline_id>", pipeline_access_token="<pipeline_token>")
sink_res = sink.consume()
```
Loading
Loading