Skip to content
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

Fix handling of PYPRIMEMESH_LAUNCH_CONTAINER environment variable during launch #549

Merged
merged 5 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions src/ansys/meshing/prime/internals/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ def launch_prime(
if ip == defaults.ip():
port = utils.get_available_local_port(port)

if 'PYPRIMEMESH_LAUNCH_CONTAINER' in os.environ:
container_name = 'ansys-prime-server'
if bool(int(os.environ.get('PYPRIMEMESH_LAUNCH_CONTAINER', '0'))):
ninad-kamat marked this conversation as resolved.
Show resolved Hide resolved
container_name = utils.make_unique_container_name('ansys-prime-server')
utils.launch_prime_github_container(port=port, name=container_name, version=version)
config.set_using_container(True)
client = Client(port=port, timeout=timeout)
Expand Down
19 changes: 19 additions & 0 deletions src/ansys/meshing/prime/internals/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@
import ansys.meshing.prime.internals.defaults as defaults

_LOCAL_PORTS = []
_PRIME_CONTAINER_COUNT = 0


def make_unique_container_name(name: str):
"""Make a unique container name.

Parameters
----------
name : str
Original name prefix that is provided.

Returns
-------
str
Unique name with a numeric integer added as suffix.
"""
global _PRIME_CONTAINER_COUNT
_PRIME_CONTAINER_COUNT = _PRIME_CONTAINER_COUNT + 1
return f'{name}-{_PRIME_CONTAINER_COUNT}'
ninad-kamat marked this conversation as resolved.
Show resolved Hide resolved


def to_camel_case(snake_str):
Expand Down
Loading