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 local doc build when docker is not available #247

Merged
merged 1 commit into from
Mar 31, 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
40 changes: 22 additions & 18 deletions .ci/start_fluent.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,30 @@ def start_fluent_container(args):
license_server = os.environ["ANSYSLMD_LICENSE_FILE"]
port = os.environ["PYFLUENT_FLUENT_PORT"]

subprocess.run(["docker", "run", "--name", "fluent_server", "-d", "--rm",
"-p", f"{port}:{port}",
"-v", f"{EXAMPLES_PATH}:{EXAMPLES_PATH}",
"-e", f"ANSYSLMD_LICENSE_FILE={license_server}",
"-e", f"REMOTING_PORTS={port}/portspan=2",
"-e", "FLUENT_LAUNCHED_FROM_PYFLUENT=1",
"ghcr.io/pyansys/pyfluent",
"-g", f"-sifile={sifile}"] + args)
try:
subprocess.run(["docker", "run", "--name", "fluent_server", "-d",
"--rm", "-p", f"{port}:{port}",
"-v", f"{EXAMPLES_PATH}:{EXAMPLES_PATH}",
"-e", f"ANSYSLMD_LICENSE_FILE={license_server}",
"-e", f"REMOTING_PORTS={port}/portspan=2",
"-e", "FLUENT_LAUNCHED_FROM_PYFLUENT=1",
"ghcr.io/pyansys/pyfluent",
"-g", f"-sifile={sifile}"] + args)

sifile_last_mtime = os.stat(sifile).st_mtime
while True:
if os.stat(sifile).st_mtime > sifile_last_mtime:
sifile_last_mtime = os.stat(sifile).st_mtime
while True:
if os.stat(sifile).st_mtime > sifile_last_mtime:
time.sleep(1)
break
if timeout == 0:
break
time.sleep(1)
break
if timeout == 0:
break
time.sleep(1)
timeout -= 1
if os.path.exists(sifile):
os.remove(sifile)
timeout -= 1
except OSError:
pass
finally:
if os.path.exists(sifile):
os.remove(sifile)


if __name__ == "__main__":
Expand Down
5 changes: 4 additions & 1 deletion .ci/stop_fluent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@


def stop_fluent_container():
subprocess.run(["docker", "stop", "fluent_server"])
try:
subprocess.run(["docker", "stop", "fluent_server"])
except OSError:
pass


if __name__ == "__main__":
Expand Down
16 changes: 9 additions & 7 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@


def _start_or_stop_fluent_container(gallery_conf, fname, when):
if when == "before":
if fname in ["mixing_elbow_settings_api.py",
"mixing_elbow_tui_api.py"]:
args = ["3ddp", "-t4", "-meshing"]
subprocess.run([sys.executable, _START_FLUENT_FILE] + args)
elif when == "after":
subprocess.run([sys.executable, _STOP_FLUENT_FILE])
start_instance = bool(int(os.getenv("PYFLUENT_START_INSTANCE", "1")))
if not start_instance:
if when == "before":
if fname in ["mixing_elbow_settings_api.py",
"mixing_elbow_tui_api.py"]:
args = ["3ddp", "-t4", "-meshing"]
subprocess.run([sys.executable, _START_FLUENT_FILE] + args)
elif when == "after":
subprocess.run([sys.executable, _STOP_FLUENT_FILE])


# -- Sphinx Gallery Options ---------------------------------------------------
Expand Down