Skip to content
Open
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
17 changes: 17 additions & 0 deletions .github/workflows/v1_testing.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: v1 Protos Testing
on:
pull_request:
workflow_dispatch:

env:
Expand Down Expand Up @@ -88,6 +89,14 @@ jobs:
run: |
pytest -v --proto-version=v1

- name: Upload integration test logs
if: always()
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: v1-windows-integration-test-logs-${{ matrix.python-version }}
path: tests/integration/logs/integration_tests_logs.txt
retention-days: 7

- name: Stop the Geometry service
if: always()
run: |
Expand Down Expand Up @@ -157,6 +166,14 @@ jobs:
run: |
pytest -v --proto-version=v1

- name: Upload integration test logs
if: always()
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: v1-linux-integration-test-logs-${{ matrix.python-version }}
path: tests/integration/logs/integration_tests_logs.txt
retention-days: 7

- name: Stop the Geometry service
if: always()
run: |
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/2464.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ci: enable v1 testing on pull request
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ classifiers = [
]

dependencies = [
"ansys-api-discovery==1.0.18",
"ansys-api-discovery==1.0.19",
"ansys-tools-common>=0.3,<1",
"beartype>=0.11.0,<0.23",
"geomdl>=5,<6",
Expand Down
41 changes: 34 additions & 7 deletions src/ansys/geometry/core/_grpc/_services/v1/commands_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,44 @@ def __init__(self, channel: grpc.Channel): # noqa: D102

@protect_grpc
def run_script_file(self, **kwargs) -> dict: # noqa: D102
from pathlib import Path
from typing import Generator

from ansys.api.discovery.v1.commands.script_pb2 import RunScriptFileRequest

# Create the request - assumes all inputs are valid and of the proper type
request = RunScriptFileRequest(
script_path=kwargs["script_path"],
script_args=kwargs["script_args"],
api_version=kwargs["api_version"],
)
import ansys.geometry.core.connection.defaults as pygeom_defaults

def request_generator(
script_path: Path,
file_path: str,
script_args: dict,
api_version: int | None,
) -> Generator[RunScriptFileRequest, None, None]:
"""Generate requests for streaming file upload."""
msg_buffer = 5 * 1024 # 5KB - for additional message data
if pygeom_defaults.MAX_MESSAGE_LENGTH - msg_buffer < 0: # pragma: no cover
raise ValueError("MAX_MESSAGE_LENGTH is too small for file upload.")

chunk_size = pygeom_defaults.MAX_MESSAGE_LENGTH - msg_buffer
with Path.open(script_path, "rb") as file:
while chunk := file.read(chunk_size):
test_req = RunScriptFileRequest(
script_path=str(file_path),
script_args=script_args,
api_version=api_version,
data=chunk,
)
yield test_req

# Call the gRPC service
response = self.stub.RunScriptFile(request)
response = self.stub.RunScriptFile(
request_generator(
script_path=kwargs["script_path"],
file_path=kwargs["original_path"],
script_args=kwargs["script_args"],
api_version=kwargs["api_version"],
)
)

# Return the response - formatted as a dictionary
return {
Expand Down
22 changes: 14 additions & 8 deletions src/ansys/geometry/core/modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,17 +587,23 @@ def run_discovery_script_file(
api_version = ApiVersions.parse_input(api_version)

# Prepare the script path
self.client.log.debug(f"Running Discovery script file at {file_path}...")
if self.client.services.version == GeometryApiProtos.V0:
serv_path = self._upload_file(file_path)
response = self.client.services.commands_script.run_script_file(
script_path=serv_path,
script_args=script_args,
api_version=api_version.value if api_version is not None else None,
)
else:
serv_path = file_path

self.client.log.debug(f"Running Discovery script file at {file_path}...")
response = self.client.services.commands_script.run_script_file(
script_path=serv_path,
script_args=script_args,
api_version=api_version.value if api_version is not None else None,
)
file_path = Path(file_path).resolve()
serv_path = prepare_file_for_server_upload(file_path)
response = self.client.services.commands_script.run_script_file(
script_path=serv_path,
original_path=file_path.name,
script_args=script_args,
api_version=api_version.value if api_version is not None else None,
)

if not response.get("success"):
raise GeometryRuntimeError(response.get("message"))
Expand Down
Loading