Skip to content

feat: using entrypoint to start MAPDL #4098

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

Merged
merged 5 commits into from
Jul 14, 2025

Conversation

germa89
Copy link
Collaborator

@germa89 germa89 commented Jul 14, 2025

Description

As the title. Additionally, enhance logging scripts and add DPF server support in CI workflows.

Issue linked

NA but related to #1300.

Checklist

Summary by Sourcery

Introduce a container entrypoint for launching MAPDL with optional DPF server support and update CI workflows and logging to integrate DPF, while adding DPF dependency detection in the Python package initialization.

New Features:

  • Add entrypoint script to start MAPDL with optional DPF GRPC server.
  • Introduce RUN_DPF_SERVER and DPF_PORT_INTERNAL flags in CI to control DPF server startup.
  • Detect ansys.dpf.core and matplotlib as optional Python package dependencies.

Enhancements:

  • Enhance start_mapdl.sh to mount the entrypoint, set DPF-related environment variables, and override distributed mode for CI versions.
  • Include DPF log directories in both local and remote log collection scripts.
  • Reorder dependency checks in init.py for clearer detection logic.

CI:

  • Add DPF_PORT_INTERNAL environment variable to GitHub Actions.
  • Remove legacy DPF startup step and configure RUN_DPF_SERVER per instance in test workflows.
  • Increase pytest --maxfail count from 5 to 10 in CI configurations.

@germa89 germa89 self-assigned this Jul 14, 2025
@Copilot Copilot AI review requested due to automatic review settings July 14, 2025 10:04
@germa89 germa89 requested a review from a team as a code owner July 14, 2025 10:04
@ansys-reviewer-bot
Copy link
Contributor

Thanks for opening a Pull Request. If you want to perform a review write a comment saying:

@ansys-reviewer-bot review

Copy link
Contributor

sourcery-ai bot commented Jul 14, 2025

Reviewer's Guide

This PR refactors the container startup by introducing a dedicated entrypoint script that initializes MAPDL and conditionally launches the DPF server, augments CI workflows with DPF support and enhanced logging, and updates the core init to detect ansys.dpf and matplotlib.

Sequence diagram for container startup with entrypoint and conditional DPF server launch

sequenceDiagram
    participant CI as CI Workflow
    participant Docker as Docker Container
    participant Entrypoint as Entrypoint Script
    participant MAPDL as MAPDL Process
    participant DPF as DPF Server
    CI->>Docker: Start container
    Docker->>Entrypoint: Run /entrypoint.sh
    Entrypoint->>Entrypoint: Check ANSYS_DPF_ACCEPT_LA or RUN_DPF_SERVER
    alt DPF server enabled
        Entrypoint->>DPF: Start DPF server
    end
    Entrypoint->>MAPDL: Start MAPDL process
Loading

Class diagram for updated core init module dependency detection

classDiagram
    class __init__ {
        +_HAS_ATP: bool
        +_HAS_CLICK: bool
        +_HAS_DPF: bool
        +_HAS_MATPLOTLIB: bool
        +_HAS_PANDAS: bool
        +_HAS_PIM: bool
        +_HAS_PYANSYS_REPORT: bool
        +_HAS_PYVISTA: bool
        +_HAS_REQUESTS: bool
        +_HAS_TQDM: bool
        +_HAS_VISUALIZER: bool
    }
Loading

File-Level Changes

Change Details Files
Introduce a unified entrypoint for container startup
  • Add .ci/entrypoint.sh to handle OMPI flags, DPF server logic, and MAPDL launch
  • Mount and invoke entrypoint.sh instead of direct EXEC_PATH call in start_mapdl.sh
  • Pass EXEC_PATH, VERSION, DISTRIBUTED_MODE, DPF_PORT_INTERNAL via environment
.ci/entrypoint.sh
.ci/start_mapdl.sh
Extend start_mapdl.sh for dynamic DPF configuration
  • Use RUN_DPF_SERVER and ANSYS_DPF_ACCEPT_LA to toggle DPF_ON flag
  • Define DPF_PORT_INTERNAL and adjust DPF_PORT_ARG mapping
  • Override DISTRIBUTED_MODE to 'dmp' for CICD images
.ci/start_mapdl.sh
Update CI workflows for DPF integration
  • Expose DPF_PORT_INTERNAL and configure RUN_DPF_SERVER in test-remote.yml and test-local.yml
  • Remove manual DPF server startup step from remote workflow
  • Adjust PYTEST_ARGUMENTS (--maxfail) and conditionally always print restart counts
.github/workflows/test-remote.yml
.github/workflows/test-local.yml
Enhance DPF log collection
  • Copy dpf_logs in both local and remote log collection scripts
.ci/collect_mapdl_logs_locals.sh
.ci/collect_mapdl_logs_remote.sh
Refactor core init flags
  • Add detection for ansys.dpf.core and reorder import checks
  • Ensure matplotlib detection precedes visualization interface flag
src/ansys/mapdl/core/__init__.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @germa89 - I've reviewed your changes - here's some feedback:

  • The CI workflows use both DPF_START_SERVER and RUN_DPF_SERVER—unify this environment variable across all scripts to avoid startup mismatches.
  • The entrypoint.sh still has hard-coded ports and a commented-out debug directory; consider parameterizing DPF_PORT_INTERNAL and enabling DATAPROCESSING_DEBUG directory creation for consistency.
  • You removed quotes around P_SCHEMA in the Docker arguments—keep variables quoted to prevent any shell word-splitting or glob-expansion issues.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The CI workflows use both DPF_START_SERVER and RUN_DPF_SERVER—unify this environment variable across all scripts to avoid startup mismatches.
- The entrypoint.sh still has hard-coded ports and a commented-out debug directory; consider parameterizing DPF_PORT_INTERNAL and enabling DATAPROCESSING_DEBUG directory creation for consistency.
- You removed quotes around P_SCHEMA in the Docker arguments—keep variables quoted to prevent any shell word-splitting or glob-expansion issues.

## Individual Comments

### Comment 1
<location> `.ci/entrypoint.sh:33` </location>
<code_context>
+echo "Starting MAPDL..."
+echo "Using executable path: ${EXEC_PATH}"
+
+$EXEC_PATH -grpc -dir /jobs -"${DISTRIBUTED_MODE}" -np 2 -db -6000 -m -6000 -
\ No newline at end of file
</code_context>

<issue_to_address>
Quoting of DISTRIBUTED_MODE may result in an invalid command-line argument.

Using quotes here causes the argument to be passed as -"dmp" instead of -dmp, which may not be recognized. Remove the quotes to ensure correct argument parsing.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@github-actions github-actions bot added CI/CD Related with CICD, Github Actions, etc maintenance General maintenance of the repo (libraries, cicd, etc) new feature Request or proposal for a new feature labels Jul 14, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Introduces a dedicated entrypoint script for launching MAPDL containers with optional DPF server support and updates CI workflows to expose new ports, control flags, and collect DPF logs.

  • Add .ci/entrypoint.sh to centralize container startup logic and conditional DPF server launch.
  • Refactor start_mapdl.sh to delegate execution to the new entrypoint and pass through environment variables for ports and modes.
  • Update GitHub Actions workflows to set DPF_PORT_INTERNAL, toggle RUN_DPF_SERVER, adjust pytest parameters, and collect DPF logs.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/ansys/mapdl/core/init.py Add _HAS_DPF flag and reorder feature-detection variables.
.github/workflows/test-remote.yml Pass DPF_PORT_INTERNAL, control RUN_DPF_SERVER, update pytest flags, remove manual DPF start block.
.github/workflows/test-local.yml Add DATAPROCESSING_DEBUG environment variable for DPF logs location.
.ci/start_mapdl.sh Update Docker run flags (DPF_PORT_ARG, ANSYS_DPF_ACCEPT_LA, entrypoint mount) and export new envs.
.ci/entrypoint.sh New entrypoint script to conditionally start the DPF server and then launch MAPDL.
.ci/collect_mapdl_logs_remote.sh Copy /home/mapdl/dpf_logs directory from container into CI artifacts.
.ci/collect_mapdl_logs_locals.sh Move /home/mapdl/dpf_logs into local log output directory.
Comments suppressed due to low confidence (2)

.github/workflows/test-remote.yml:268

  • The upload-artifact step has no "if: always()" condition, so artifacts may not be uploaded on failure. Consider adding if: always() to ensure logs are collected even if earlier steps fail.
      - name: "Upload pytest reports to GitHub"

.github/workflows/test-local.yml:126

  • The DATAPROCESSING_DEBUG variable is set but never referenced elsewhere in the workflow or scripts. Confirm whether it’s needed or remove it.
      DATAPROCESSING_DEBUG: /home/mapdl/dpf_logs

@germa89 germa89 enabled auto-merge (squash) July 14, 2025 10:20
@germa89
Copy link
Collaborator Author

germa89 commented Jul 14, 2025

@pyansys-ci-bot LGTM.

Copy link
Contributor

@pyansys-ci-bot pyansys-ci-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approving this PR because germa89 said so in here 😬

LGTM

Copy link

codecov bot commented Jul 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.81%. Comparing base (a9d37dc) to head (749291b).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4098      +/-   ##
==========================================
- Coverage   91.82%   91.81%   -0.01%     
==========================================
  Files         187      187              
  Lines       15033    15034       +1     
==========================================
  Hits        13804    13804              
- Misses       1229     1230       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@germa89 germa89 merged commit b1b3336 into main Jul 14, 2025
78 of 80 checks passed
@germa89 germa89 deleted the ci/using-entrypoint-for-starting-mapdl branch July 14, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/CD Related with CICD, Github Actions, etc maintenance General maintenance of the repo (libraries, cicd, etc) new feature Request or proposal for a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants