Set CONTAINER_USER_DATA via PYPRIMEMESH_CONTAINER_USER_DATA env variable
Closed this issue ยท 0 comments
anscfrisson commented
๐ Description of the feature
Running github actions with tests using pyprimemesh containers locally via nektos act fails.
Example .github/workflows/ci_cd.yml
file contents
env:
DOCKER_IMAGE_NAME: ***
DOCKER_IMAGE_TAG: ***
tests:
name: "Tests"
timeout-minutes: 10
runs-on: ubuntu-latest
needs: [smoke-tests]
steps:
- name: Login in Github Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ***
password: ***
- name: Pull Ansys Prime Server
run: docker pull ${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG }}
- uses: ansys/actions/tests-pytest@bd279a8d2c5d6e140c0cce93f77df8d5c5021840 # until v > 5.1.9 is released
env:
PYPRIMEMESH_LAUNCH_CONTAINER: 1
PYPRIMEMESH_IMAGE_TAG: ${{ env.DOCKER_IMAGE_TAG }}
ANSYSLMD_LICENSE_FILE: ***
with:
pytest-extra-args: "--cov=ansys --cov-report=term --cov-report=html:.cov/html"
skip-install: false
Example tests file contents
filename = cwd + "/tests/mixing_elbow.pmdat"
# Commands syntaxes...
# This executes a command without having to create a command instance
# the arguments are optional and "None" is used if not provided
execute_command(
"prime",
"file",
"readcad",
initial_path=filename,
)
Tracing the issue
def file_read_context(model, file_name: str):
#...
if config.using_container():
base_file_name = os.path.basename(file_name)
temp_file_name = os.path.join(defaults.get_examples_path(), base_file_name)
is_copy: bool = file_name != temp_file_name
if is_copy:
shutil.copyfile(file_name, temp_file_name)
container_file_name = os.path.join(
defaults.get_examples_path_for_containers(), base_file_name
)
container_file_name = container_file_name.replace(os.path.sep, '/')
yield container_file_name
CONTAINER_USER_DATA = '/data'
CONTAINER_EXAMPLES = os.path.join(CONTAINER_USER_DATA, 'examples')
#...
def get_examples_path_for_containers():
"""Get the server-side default container path in case of containers.
In case of a container, the user data directory is mounted within the container image.
"""
return CONTAINER_EXAMPLES
Conclusion
pyprimemesh when run in containers expects readcad
to find files in CONTAINER_EXAMPLES
under CONTAINER_USER_DATA
.
More flexibility on CONTAINER_USER_DATA
would be welcome.
๐ก Steps for implementing the feature
replace:
CONTAINER_USER_DATA = '/data'
by:
CONTAINER_USER_DATA = os.getenv('PYPRIMEMESH_CONTAINER_USER_DATA ', '/data')
๐ Useful links and references
No response
Repository is internal.