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

Update examples to use core.make_tmp_dir_server #936

Merged
merged 3 commits into from
Jul 17, 2023
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
7 changes: 1 addition & 6 deletions examples/05-file-IO/00-hdf5_double_float_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# temporary directory.

import os
import tempfile

from ansys.dpf import core as dpf
from ansys.dpf.core import examples
Expand All @@ -42,7 +41,6 @@
# and displacement).

timeIds = list(range(1, model.metadata.time_freq_support.n_sets + 1))
timeIds

stress.inputs.time_scoping.connect(timeIds)
displacement.inputs.time_scoping.connect(timeIds)
Expand All @@ -56,10 +54,7 @@

###############################################################################
# Define a temporary folder for outputs
if dpf.SERVER.local_server:
tmpdir = tempfile.mkdtemp()
else:
tmpdir = "/tmp"
tmpdir = dpf.core.make_tmp_dir_server(dpf.SERVER)
files = [
dpf.path_utilities.join(tmpdir, "dpf_float.h5"),
dpf.path_utilities.join(tmpdir, "dpf_double.h5"),
Expand Down
7 changes: 1 addition & 6 deletions examples/05-file-IO/01-reduced_matrices_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# Import the ``dpf-core`` module and its examples files, and then create a
# temporary directory.

import tempfile

from ansys.dpf import core as dpf
from ansys.dpf.core import examples
from ansys.dpf.core import operators as ops
Expand All @@ -38,10 +36,7 @@

###############################################################################
# Define a temporary folder for outputs
if dpf.SERVER.local_server:
tmpdir = tempfile.mkdtemp()
else:
tmpdir = "/tmp/"
tmpdir = dpf.core.make_tmp_dir_server(dpf.SERVER)

###############################################################################
# Export the result fields container to an HDF5 file.
Expand Down
2 changes: 1 addition & 1 deletion examples/05-file-IO/04-basic-load-file.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# Define an output path for the resulting .csv file
if not dpf.SERVER.local_server:
# Define it server-side if using a remote server
tmp_dir_path = "/tmp/"
tmp_dir_path = dpf.core.make_tmp_dir_server(dpf.SERVER)
server_file_path = dpf.path_utilities.join(tmp_dir_path, csv_file_name)
else:
server_file_path = os.path.join(os.getcwd(), csv_file_name)
Expand Down