diff --git a/.github/workflows/v1_testing.yml b/.github/workflows/v1_testing.yml index 10ff900d55..268f832150 100644 --- a/.github/workflows/v1_testing.yml +++ b/.github/workflows/v1_testing.yml @@ -1,5 +1,6 @@ name: v1 Protos Testing on: + pull_request: workflow_dispatch: env: @@ -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: | @@ -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: | diff --git a/doc/changelog.d/2464.maintenance.md b/doc/changelog.d/2464.maintenance.md new file mode 100644 index 0000000000..9004c6458a --- /dev/null +++ b/doc/changelog.d/2464.maintenance.md @@ -0,0 +1 @@ +Ci: enable v1 testing on pull request diff --git a/pyproject.toml b/pyproject.toml index 6dcce56953..2130d6c232 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ classifiers = [ ] dependencies = [ - "ansys-api-discovery==1.0.19", + "ansys-api-discovery==1.0.20", "ansys-tools-common>=0.3,<1", "beartype>=0.11.0,<0.23", "geomdl>=5,<6", diff --git a/src/ansys/geometry/core/_grpc/_services/v1/commands_script.py b/src/ansys/geometry/core/_grpc/_services/v1/commands_script.py index c060fd79c6..daacdbc1ba 100644 --- a/src/ansys/geometry/core/_grpc/_services/v1/commands_script.py +++ b/src/ansys/geometry/core/_grpc/_services/v1/commands_script.py @@ -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 { diff --git a/src/ansys/geometry/core/modeler.py b/src/ansys/geometry/core/modeler.py index 3641234825..c281dd68f1 100644 --- a/src/ansys/geometry/core/modeler.py +++ b/src/ansys/geometry/core/modeler.py @@ -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"))