Skip to content

Explain how to add license server access to SpeosRPC docker container creation #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 12, 2022
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: 2 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ jobs:
pytest -vx
docker kill pyoptics_speos-rpc
docker rm pyoptics_speos-rpc
env:
LICENSE_SERVER: 1055@${{ secrets.LICENSE_SERVER }}

- name: Upload wheel
uses: actions/upload-artifact@v2
Expand Down
8 changes: 6 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,14 @@ The configuration file `<tests/local_config.json>`_ located in tests folder cont
Start server
~~~~~~~~~~~~
First options is to use the Docker container of `SpeosRPC_Server <https://github.com/orgs/pyansys/packages/container/package/pyoptics%2Fspeos-rpc>`_.
It can be started using `<docker-compose.yml>`_ (if needed, please provide GitHub username and PAT as password) :
It can be started using `<docker-compose.yml>`_ (if needed, please provide GitHub username and PAT as password)
Since the docker image contains no license server, you will need to enter your license server IP address in the `LICENSE_SERVER` environment variable.
With that, you can launch SpeosRPC server with:

.. code::


export [email protected]

docker login ghcr.io/pyansys/pyoptics
docker-compose up -d

Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ services:
container_name: pyoptics_speos-rpc
ports:
- "50051:50051"
environment:
- SPEOS_LOG_LEVEL=2
- ANSYSLMD_LICENSE_FILE=$LICENSE_SERVER
entrypoint: ./SpeosRPC_Server.x
volumes:
- type: bind
Expand Down
18 changes: 17 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@
import json
import os

local_path = os.path.dirname(os.path.realpath(__file__))
import grpc


def grpc_server_on(config) -> bool:
TIMEOUT_SEC = 60
try:
with grpc.insecure_channel(f"localhost:" + str(config.get("SpeosServerPort"))) as channel:
grpc.channel_ready_future(channel).result(timeout=TIMEOUT_SEC)
return True
except:
return False


local_path = os.path.dirname(os.path.realpath(__file__))

# Load the local config file
local_config_file = os.path.join(local_path, "local_config.json")
if os.path.exists(local_config_file):
Expand All @@ -27,3 +39,7 @@
test_path = "/app/assets/"
else:
test_path = os.path.join(local_path, "assets/")

# Wait for the grpc server - in case the timeout is reached raise an error
if not grpc_server_on(config):
raise ValueError("Start SpeosRPC_Server - Timeout reached.")