lint and re-arm the flake8 test

This commit is contained in:
Kenneth Bingham 2025-03-04 19:53:04 -05:00
parent 0851e3e560
commit ef10caa21f
No known key found for this signature in database
GPG Key ID: 31709281860130B6
6 changed files with 21 additions and 22 deletions

View File

@ -1,6 +1,5 @@
[flake8] [flake8]
max-line-length = 120 max-line-length = 120
exclude = exclude =
./sdk/python/sdk/**,
./build/** ./build/**

View File

@ -27,7 +27,7 @@ jobs:
needs: enforce_stable_semver needs: enforce_stable_semver
defaults: defaults:
run: run:
working-directory: sdk/python/sdk/zrok working-directory: sdk/python/src
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -62,7 +62,7 @@ jobs:
if: startsWith(matrix.spec.name, 'linux') if: startsWith(matrix.spec.name, 'linux')
with: with:
name: zrok_sdk_${{ matrix.spec.target }} name: zrok_sdk_${{ matrix.spec.target }}
path: ${{ github.workspace }}/sdk/python/sdk/zrok/dist/* path: dist/*
publish-testpypi: publish-testpypi:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

View File

@ -72,7 +72,7 @@ jobs:
- name: python lint - name: python lint
shell: bash shell: bash
run: flake8 sdk/python/sdk/zrok run: flake8 sdk/python/src
- name: solve GOBIN - name: solve GOBIN
id: solve_go_bin id: solve_go_bin
@ -91,6 +91,9 @@ jobs:
pytest: pytest:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
defaults:
run:
working-directory: sdk/python/src
strategy: strategy:
matrix: matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"] python-version: ["3.10", "3.11", "3.12", "3.13"]
@ -105,7 +108,6 @@ jobs:
- name: Install dependencies - name: Install dependencies
shell: bash shell: bash
working-directory: sdk/python/src/
run: | run: |
set -o pipefail set -o pipefail
@ -118,7 +120,6 @@ jobs:
- name: Test with pytest - name: Test with pytest
shell: bash shell: bash
working-directory: sdk/python/src/
run: | run: |
set -o pipefail set -o pipefail

9
.gitignore vendored
View File

@ -16,8 +16,6 @@ node_modules/
.docusaurus .docusaurus
.cache-loader .cache-loader
sdk/python/sdk/build/
# Misc # Misc
.DS_Store .DS_Store
.env.local .env.local
@ -39,6 +37,7 @@ yarn-error.log*
sdk/nodejs/sdk/dist sdk/nodejs/sdk/dist
# py module artifacts # py module artifacts
*.egg-info/ /sdk/python/src/**/*.egg-info/
__pycache__/ /sdk/python/src/**/__pycache__/
.coverage /.coverage
/sdk/python/src/dist/

View File

@ -48,16 +48,16 @@ class Root:
cfg = Configuration() cfg = Configuration()
cfg.host = apiEndpoint[0] + "/api/v1" cfg.host = apiEndpoint[0] + "/api/v1"
# Update: Configure authentication token # Update: Configure authentication token
# The token needs to be set with 'key' instead of 'x-token' # The token needs to be set with 'key' instead of 'x-token'
# This matches the securityDefinitions in the OpenAPI spec # This matches the securityDefinitions in the OpenAPI spec
cfg.api_key["key"] = self.env.Token cfg.api_key["key"] = self.env.Token
# Create the API client with the configured authentication # Create the API client with the configured authentication
auth_client = zrok.ApiClient(configuration=cfg) auth_client = zrok.ApiClient(configuration=cfg)
self.client_version_check(auth_client) self.client_version_check(auth_client)
return auth_client return auth_client
def ApiEndpoint(self) -> ApiEndpoint: def ApiEndpoint(self) -> ApiEndpoint:

View File

@ -1,4 +1,3 @@
from zrok import model
from zrok_api.api import ShareApi from zrok_api.api import ShareApi
from zrok.environment.root import Root from zrok.environment.root import Root
from zrok_api.models.auth_user import AuthUser from zrok_api.models.auth_user import AuthUser
@ -58,7 +57,7 @@ def CreateShare(root: Root, request: model.ShareRequest) -> model.Share:
zrok = root.Client() zrok = root.Client()
except Exception as e: except Exception as e:
raise Exception("error getting zrok client", e) raise Exception("error getting zrok client", e)
try: try:
# Use share_with_http_info to get access to the HTTP info and handle custom response format # Use share_with_http_info to get access to the HTTP info and handle custom response format
share_api = ShareApi(zrok) share_api = ShareApi(zrok)
@ -66,18 +65,18 @@ def CreateShare(root: Root, request: model.ShareRequest) -> model.Share:
custom_headers = { custom_headers = {
'Accept': 'application/json, application/zrok.v1+json' 'Accept': 'application/json, application/zrok.v1+json'
} }
response_data = share_api.share_with_http_info( response_data = share_api.share_with_http_info(
body=out, body=out,
_headers=custom_headers _headers=custom_headers
) )
# Parse response # Parse response
if hasattr(response_data, 'data') and response_data.data is not None: if hasattr(response_data, 'data') and response_data.data is not None:
res = response_data.data res = response_data.data
else: else:
raise Exception("invalid response from server") raise Exception("invalid response from server")
except ApiException as e: except ApiException as e:
# If it's a content type error, try to parse the raw JSON # If it's a content type error, try to parse the raw JSON
if "Unsupported content type: application/zrok.v1+json" in str(e) and hasattr(e, 'body'): if "Unsupported content type: application/zrok.v1+json" in str(e) and hasattr(e, 'body'):
@ -85,11 +84,12 @@ def CreateShare(root: Root, request: model.ShareRequest) -> model.Share:
# Parse the response body directly # Parse the response body directly
res_dict = json.loads(e.body) res_dict = json.loads(e.body)
# Create a response object with the expected fields # Create a response object with the expected fields
class ShareResponse: class ShareResponse:
def __init__(self, share_token, frontend_proxy_endpoints): def __init__(self, share_token, frontend_proxy_endpoints):
self.share_token = share_token self.share_token = share_token
self.frontend_proxy_endpoints = frontend_proxy_endpoints self.frontend_proxy_endpoints = frontend_proxy_endpoints
res = ShareResponse( res = ShareResponse(
share_token=res_dict.get('shareToken', ''), share_token=res_dict.get('shareToken', ''),
frontend_proxy_endpoints=res_dict.get('frontendProxyEndpoints', []) frontend_proxy_endpoints=res_dict.get('frontendProxyEndpoints', [])
@ -149,7 +149,7 @@ def DeleteShare(root: Root, shr: model.Share):
custom_headers = { custom_headers = {
'Accept': 'application/json, application/zrok.v1+json' 'Accept': 'application/json, application/zrok.v1+json'
} }
# Use unshare_with_http_info to get access to the HTTP info # Use unshare_with_http_info to get access to the HTTP info
share_api.unshare_with_http_info( share_api.unshare_with_http_info(
body=req, body=req,
@ -182,7 +182,7 @@ def ReleaseReservedShare(root: Root, shr: model.Share):
custom_headers = { custom_headers = {
'Accept': 'application/json, application/zrok.v1+json' 'Accept': 'application/json, application/zrok.v1+json'
} }
# Use unshare_with_http_info to get access to the HTTP info # Use unshare_with_http_info to get access to the HTTP info
share_api.unshare_with_http_info( share_api.unshare_with_http_info(
body=req, body=req,