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

mfkrogh/docker launcher enshell #173

Merged
merged 18 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
7 changes: 7 additions & 0 deletions src/ansys/pyensight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@
from ansys.pyensight.dockerlauncher import DockerLauncher
except Exception:
pass

try:
from ansys.pyensight.dockerlauncherenshell import DockerLauncherEnShell
except Exception:
pass

from ansys.pyensight.launch_ensight import launch_ensight
23 changes: 15 additions & 8 deletions src/ansys/pyensight/dockerlauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
launcher = DockerLauncher(data_directory="D:\\data")
launcher.pull()
session = launcher.start()
launcher.stop()
session.close()

"""
import os.path
Expand Down Expand Up @@ -39,6 +39,11 @@ class DockerLauncher(pyensight.Launcher):
In some cases where the EnSight session can take a significant amount of
timme to start up, this is the number of seconds to wait before failing
the connection. The default is 120.0.
use_egl:
If True, EGL hardware accelerated graphics will be used. The platform
must be able to support it.
use_sos:
If None, don't use SOS. Otherwise, it's the number of EnSight Servers to use (int).

Examples:
::
Expand All @@ -47,7 +52,7 @@ class DockerLauncher(pyensight.Launcher):
launcher = DockerLauncher(data_directory="D:\\data")
launcher.pull()
session = launcher.start()
launcher.stop()
session.close()

"""

Expand All @@ -57,10 +62,11 @@ def __init__(
docker_image_name: Optional[str] = None,
use_dev: bool = False,
timeout: float = 120.0,
use_egl: bool = False,
use_sos: Optional[int] = None,
) -> None:
super().__init__()
super().__init__(timeout, use_egl, use_sos)

self._timeout = timeout
self._data_directory: str = data_directory
self._container = None

Expand Down Expand Up @@ -118,16 +124,14 @@ def pull(self) -> None:
except Exception:
raise RuntimeError(f"Can't pull Docker image: {self._image_name}")

def start(self, host: str = "127.0.0.1", use_egl: bool = False) -> "pyensight.Session":
def start(self, host: str = "127.0.0.1") -> "pyensight.Session":
"""Start an EnSight session using the local Docker ensight image
Launch a copy of EnSight in the container that supports the gRPC interface. Create and
bind a Session instance to the created gRPC session. Return that session.

Args:
host:
Optional hostname on which the EnSight gRPC service is running
use_egl:
Specify True if EnSight should try to use EGL. Beta flag.

Returns:
pyensight Session object instance
Expand Down Expand Up @@ -180,7 +184,7 @@ def start(self, host: str = "127.0.0.1", use_egl: bool = False) -> "pyensight.Se
# FIXME_MFK: probably need a unique name for our container
# in case the user launches multiple sessions
egl_env = os.environ.get("PYENSIGHT_FORCE_ENSIGHT_EGL")
use_egl = use_egl or egl_env or self._has_egl()
use_egl = self._use_egl or egl_env or self._has_egl()
if use_egl:
self._container = self._docker_client.containers.run(
self._image_name,
Expand Down Expand Up @@ -250,6 +254,9 @@ def start(self, host: str = "127.0.0.1", use_egl: bool = False) -> "pyensight.Se
if use_egl:
cmd2 += " -egl"

if self._use_sos:
cmd2 += " -sos -nservers " + str(int(self._use_sos))

cmd2 += " -grpc_server " + str(ports[0])

vnc_url = f"vnc://%%3Frfb_port={ports[1]}%%26use_auth=0"
Expand Down
Loading