Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 11 additions & 9 deletions .github/actions/prepare-poetry/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
---

name: Prepare Python and Poetry
Description: Install Python, Poetry and dev dependencies, cached for speed
description: Install Python, Poetry and dev dependencies, cached for speed

inputs:
python-version:
Expand All @@ -18,38 +18,40 @@ runs:
steps:
- name: Set up Python
id: setup-python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Load cached Poetry installation
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.local # the path depends on the OS
key: poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-0 # increment to reset cache
key: poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-4 # increment to reset cache

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true
virtualenvs-in-project: false

- name: Install Poetry Plugins
run: |
python -m pip install --upgrade pip
pip install poetry-dynamic-versioning
shell: bash

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-1


- name: Install Poetry Plugins
run: poetry self add "poetry-dynamic-versioning[plugin]"
shell: bash

- name: Install dependencies and library
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction
shell: bash

17 changes: 9 additions & 8 deletions .github/workflows/ci-publish-test-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

on:
push:
tags:
- '*'
branches:
- main
pull_request:

jobs:
build:
Expand All @@ -16,7 +17,7 @@ jobs:
steps:

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -36,7 +37,7 @@ jobs:
poetry build

- name: Save build artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: dist-artifact
path: dist/
Expand All @@ -53,12 +54,12 @@ jobs:
python-version: '3.9'

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get build artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist-artifact
path: dist/
Expand Down Expand Up @@ -90,12 +91,12 @@ jobs:

# Retrieve the code and GIT history so that poetry-dynamic-versioning knows which version to upload
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get build artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist-artifact
path: dist/
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -54,12 +54,12 @@ jobs:
python-version: '3.9'

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get build artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist-artifact
path: dist/
Expand Down Expand Up @@ -91,12 +91,12 @@ jobs:

# Retrieve the code and GIT history so that poetry-dynamic-versioning knows which version to upload
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get build artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist-artifact
path: dist/
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/prepare-poetry
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install dependencies
uses: ./.github/actions/prepare-poetry
Expand All @@ -69,13 +69,13 @@ jobs:

- name: Upload pytest artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Unit Test Results (Python ${{ matrix.python-version }})
path: pytest.xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -45,4 +45,4 @@ jobs:
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.vscode
*.sublime-project
*.sublime-workspace
*.iml

# Checkpoints
.ipynb_checkpoints
Expand Down
44 changes: 25 additions & 19 deletions etpproto/client_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,31 @@ def getCapability(self, name: str) -> Any:

def negotiate(self, msg: Union[OpenSession, RequestSession]):
for k, v in msg.endpoint_capabilities.items():
cap_class = kind_from_name(k)
# if cap_class != None:
val: Any = v
if hasattr(val, "item"):
val = v.item # if it is a DataValue

if k in self.endpoint_capabilities:
try:
val = min(val, self.endpoint_capabilities[k])
except Exception as e1:
logging.debug(e1)

if cap_class is not None:
if cap_class._min is not None:
val = max(val, cap_class._min)
if cap_class._max is not None:
val = min(val, cap_class._max)

self.endpoint_capabilities[k] = val
try:
cap_class = kind_from_name(k)
# if cap_class != None:
val: Any = v
if hasattr(val, "item"):
val = v.item # if it is a DataValue

if k in self.endpoint_capabilities:
try:
val = min(val, self.endpoint_capabilities[k])
except Exception as e1:
logging.debug(e1)

if cap_class is not None:
if cap_class._min is not None:
val = max(val, cap_class._min)
if cap_class._max is not None:
val = min(val, cap_class._max)

self.endpoint_capabilities[k] = val
except Exception as e:
logging.error(e)
logging.error(
f"{str(self)}: @clientinfo.negotiate Error with {k}, {v}"
)

logging.debug(f"Negotiated capa : {self.endpoint_capabilities}")
# else:
Expand Down
8 changes: 4 additions & 4 deletions etpproto/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ async def _handle_message_generator(
if (
etp_input_msg is not None and etp_input_msg.header is not None
): # si pas un message none
current_msg_id = etp_input_msg.header.message_id
if not self.auth_required or (
self.client_info is not None
and (
Expand All @@ -215,8 +216,6 @@ async def _handle_message_generator(
== CommunicationProtocol.CORE.value
or self.is_connected
):
current_msg_id = etp_input_msg.header.message_id

# if requires acknowledge :
if (
etp_input_msg.is_asking_acknowledge()
Expand Down Expand Up @@ -370,11 +369,12 @@ async def _handle_message_generator(
raise e
else: # not connected
yield InvalidStateError().to_etp_message(
msg_id=self.consume_msg_id()
msg_id=self.consume_msg_id(),
correlation_id=current_msg_id,
)
else: # not authenticated
yield AuthorizationRequired().to_etp_message(
msg_id=self.consume_msg_id()
msg_id=self.consume_msg_id(), correlation_id=current_msg_id
)
else: # null message
yield InvalidMessageError().to_etp_message(
Expand Down
Loading
Loading