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
2 changes: 1 addition & 1 deletion .github/actions/run_and_upload_unit_tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ runs:
run: echo "osVersion=$ImageOS" >> "$GITHUB_ENV"
shell: bash
- name: Cache ${{ inputs.package-name }} virtualenv
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ${{ github.workspace }}/${{ inputs.package-basepath }}/${{ inputs.package-name }}/.venv
key: ${{ inputs.package-name }}-${{ runner.os }}-py${{ env.pythonVersion }}-${{ hashFiles(format('{0}/{1}/poetry.lock', inputs.package-basepath, inputs.package-name)) }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check_analyzers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ jobs:
with:
submodules: true
- name: Set up Python
uses: ni/python-actions/setup-python@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/setup-python@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
id: setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: ni/python-actions/setup-poetry@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/setup-poetry@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
- name: Analyze Python Project
uses: ni/python-actions/analyze-project@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/analyze-project@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
with:
project-directory: ${{ github.workspace }}/${{ inputs.package-basepath }}/${{ inputs.package-name }}
extras: ${{ inputs.install-extras }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check_codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ jobs:
with:
submodules: true
- name: Set up Python
uses: ni/python-actions/setup-python@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/setup-python@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
id: setup-python
- name: Set up Poetry
uses: ni/python-actions/setup-poetry@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/setup-poetry@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
- name: Check for lock changes
run: poetry check --lock
- name: Cache virtualenv
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ${{ github.workspace }}/tools/grpc_generator/.venv
key: grpc_generator-only-main-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('tools/grpc_generator/poetry.lock') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ jobs:
- name: Check out repo
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Set up Python
uses: ni/python-actions/setup-python@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/setup-python@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
id: setup-python
- name: Set up Poetry
uses: ni/python-actions/setup-poetry@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/setup-poetry@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
- name: Check for lock changes
run: poetry check --lock
- name: Cache virtualenv (with docs)
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ${{ github.workspace }}/${{ inputs.package-basepath }}/${{ inputs.package-name }}/.venv
key: ${{ inputs.package-name }}-with-docs-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles(format('{0}/{1}/poetry.lock', inputs.package-basepath, inputs.package-name)) }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ jobs:
- name: Check out repo
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Set up Python
uses: ni/python-actions/setup-python@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/setup-python@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
- name: Set up Poetry
uses: ni/python-actions/setup-poetry@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/setup-poetry@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
- name: Check project version
if: github.event_name == 'release'
uses: ni/python-actions/check-project-version@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/check-project-version@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
with:
project-directory: ./${{ needs.get_package_info.outputs.package-basepath }}/${{ needs.get_publish_info.outputs.package-name }}
expected-version: ${{ needs.get_publish_info.outputs.package-version }}
Expand Down Expand Up @@ -152,11 +152,11 @@ jobs:
- name: Check out repo
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Set up Python
uses: ni/python-actions/setup-python@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/setup-python@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
- name: Set up Poetry
uses: ni/python-actions/setup-poetry@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/setup-poetry@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
- name: Update project version
uses: ni/python-actions/update-project-version@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/update-project-version@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
with:
project-directory: ./${{ needs.get_package_info.outputs.package-basepath }}/${{ needs.get_publish_info.outputs.package-name }}
branch-prefix: users/build/${{ needs.get_publish_info.outputs.package-name }}-
4 changes: 2 additions & 2 deletions .github/workflows/run_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ jobs:
with:
submodules: true
- name: Set up Python
uses: ni/python-actions/setup-python@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/setup-python@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
id: setup-python
with:
python-version: ${{ inputs.python-version }}
- name: Set up Poetry
uses: ni/python-actions/setup-poetry@1b90235a5fcc5e52f0e39e8d2ae9e91d3e3903f2 # v0.6.0
uses: ni/python-actions/setup-poetry@f42e2f27a585f5d47efcab79b608ec0ec97191c9 # v0.6.1
- name: Run and upload unit tests for ${{ inputs.package-name }}
uses: ./.github/actions/run_and_upload_unit_tests
with:
Expand Down
8 changes: 4 additions & 4 deletions packages/ni-grpc-extensions/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions packages/ni-grpc-extensions/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ traceloggingdynamic = { version = ">=1.0", platform = "win32" }

[tool.poetry.group.dev.dependencies]
types-grpcio = ">=1.0"
# Install traceloggingdynamic on Linux for type checking.
traceloggingdynamic = { version = ">=1.0", platform = "linux" }

[tool.poetry.group.lint.dependencies]
bandit = { version = ">=1.7", extras = ["toml"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
import ctypes
import sys
import uuid
from typing import TYPE_CHECKING
from typing import Any

if sys.platform == "win32":
try:
import traceloggingdynamic
import traceloggingdynamic

_event_provider: traceloggingdynamic.Provider | None = traceloggingdynamic.Provider(
b"NI-Grpc-Python"
)
except ImportError:
_event_provider = None
else:
if TYPE_CHECKING:
import traceloggingdynamic
_event_provider = traceloggingdynamic.Provider(b"NI-Grpc-Python")

def _create_event_builder() -> traceloggingdynamic.EventBuilder:
return traceloggingdynamic.EventBuilder()

else:
_event_provider = None

def _create_event_builder() -> Any:
raise RuntimeError(f"ETW logging is not supported on {sys.platform}")


_LEVEL_LOG_ALWAYS = 0
_LEVEL_CRITICAL = 1
_LEVEL_ERROR = 3
Expand Down Expand Up @@ -87,7 +87,7 @@ def is_enabled() -> bool:
def log_grpc_client_call_start(method_name: str) -> uuid.UUID | None:
"""Log when starting a gRPC client call."""
if _event_provider and _event_provider.is_enabled(level=_LEVEL_INFO, keyword=_KEYWORD_GRPC):
eb = traceloggingdynamic.EventBuilder() # pyright: ignore[reportPossiblyUnboundVariable]
eb = _create_event_builder()
eb.reset(
b"GrpcClientCall",
level=_LEVEL_INFO,
Expand All @@ -107,7 +107,7 @@ def log_grpc_client_call_start(method_name: str) -> uuid.UUID | None:
def log_grpc_client_call_stop(method_name: str, activity_id: uuid.UUID | None = None) -> None:
"""Log when a gRPC client call has completed."""
if _event_provider and _event_provider.is_enabled(level=_LEVEL_INFO, keyword=_KEYWORD_GRPC):
eb = traceloggingdynamic.EventBuilder() # pyright: ignore[reportPossiblyUnboundVariable]
eb = _create_event_builder()
eb.reset(
b"GrpcClientCall",
level=_LEVEL_INFO,
Expand All @@ -122,7 +122,7 @@ def log_grpc_client_call_stop(method_name: str, activity_id: uuid.UUID | None =
def log_grpc_client_call_streaming_request(method_name: str) -> None:
"""Log when a gRPC client call is sending a client-streaming request."""
if _event_provider and _event_provider.is_enabled(level=_LEVEL_INFO, keyword=_KEYWORD_GRPC):
eb = traceloggingdynamic.EventBuilder() # pyright: ignore[reportPossiblyUnboundVariable]
eb = _create_event_builder()
eb.reset(
b"GrpcClientCallStreamingRequest",
level=_LEVEL_INFO,
Expand All @@ -136,7 +136,7 @@ def log_grpc_client_call_streaming_request(method_name: str) -> None:
def log_grpc_client_call_streaming_response(method_name: str) -> None:
"""Log when a gRPC client call has received a server-streaming response."""
if _event_provider and _event_provider.is_enabled(level=_LEVEL_INFO, keyword=_KEYWORD_GRPC):
eb = traceloggingdynamic.EventBuilder() # pyright: ignore[reportPossiblyUnboundVariable]
eb = _create_event_builder()
eb.reset(
b"GrpcClientCallStreamingResponse",
level=_LEVEL_INFO,
Expand All @@ -150,7 +150,7 @@ def log_grpc_client_call_streaming_response(method_name: str) -> None:
def log_grpc_server_call_start(method_name: str) -> uuid.UUID | None:
"""Log when starting a gRPC server call."""
if _event_provider and _event_provider.is_enabled(level=_LEVEL_INFO, keyword=_KEYWORD_GRPC):
eb = traceloggingdynamic.EventBuilder() # pyright: ignore[reportPossiblyUnboundVariable]
eb = _create_event_builder()
eb.reset(
b"GrpcServerCall",
level=_LEVEL_INFO,
Expand All @@ -170,7 +170,7 @@ def log_grpc_server_call_start(method_name: str) -> uuid.UUID | None:
def log_grpc_server_call_stop(method_name: str, activity_id: uuid.UUID | None = None) -> None:
"""Log when a gRPC server call has completed."""
if _event_provider and _event_provider.is_enabled(level=_LEVEL_INFO, keyword=_KEYWORD_GRPC):
eb = traceloggingdynamic.EventBuilder() # pyright: ignore[reportPossiblyUnboundVariable]
eb = _create_event_builder()
eb.reset(
b"GrpcServerCall",
level=_LEVEL_INFO,
Expand All @@ -185,7 +185,7 @@ def log_grpc_server_call_stop(method_name: str, activity_id: uuid.UUID | None =
def log_grpc_server_call_streaming_request(method_name: str) -> None:
"""Log when a gRPC server call is sending a server-streaming request."""
if _event_provider and _event_provider.is_enabled(level=_LEVEL_INFO, keyword=_KEYWORD_GRPC):
eb = traceloggingdynamic.EventBuilder() # pyright: ignore[reportPossiblyUnboundVariable]
eb = _create_event_builder()
eb.reset(
b"GrpcServerCallStreamingRequest",
level=_LEVEL_INFO,
Expand All @@ -199,7 +199,7 @@ def log_grpc_server_call_streaming_request(method_name: str) -> None:
def log_grpc_server_call_streaming_response(method_name: str) -> None:
"""Log when a gRPC server call has received a server-streaming response."""
if _event_provider and _event_provider.is_enabled(level=_LEVEL_INFO, keyword=_KEYWORD_GRPC):
eb = traceloggingdynamic.EventBuilder() # pyright: ignore[reportPossiblyUnboundVariable]
eb = _create_event_builder()
eb.reset(
b"GrpcServerCallStreamingResponse",
level=_LEVEL_INFO,
Expand Down
Loading