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

feat: apdl submodule #3385

Open
wants to merge 37 commits into
base: feat/main_commands
Choose a base branch
from
Open

feat: apdl submodule #3385

wants to merge 37 commits into from

Conversation

clatapie
Copy link
Contributor

@clatapie clatapie commented Sep 5, 2024

This PR is the first one in order to automate the PyMAPDL _commands documentation.
The changes have been generated using pyconverter-xml2py.

This PR focus on the apdl submodule.

Pinging @ansys/pymapdl-developers for visibility. Feel free to provide any feedback on the way the docstrings and the source code generation are handled.

Note

This PR is meant to be merged within the feat/main_commands branch. The latter will gather all the submodule changes, one by one, prior to be merged to the main branch.

Checklist

@clatapie clatapie added documentation Documentation related (improving, adding, etc) enhancement Improve any current implemented feature labels Sep 5, 2024
@clatapie clatapie self-assigned this Sep 5, 2024
@clatapie clatapie requested a review from a team as a code owner September 5, 2024 16:03
@clatapie clatapie requested review from germa89 and pyansys-ci-bot and removed request for a team September 5, 2024 16:03
@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

@clatapie clatapie requested a review from RobPasMue September 5, 2024 16:04
@github-actions github-actions bot added new feature Request or proposal for a new feature and removed documentation Documentation related (improving, adding, etc) labels Sep 5, 2024
@germa89
Copy link
Collaborator

germa89 commented Sep 5, 2024

I am setting this PR as draft because I think it is still not ready until you fix the line length thing.

Ping us and switch this PR to non-draft when you feel it is ready for it.

@germa89 germa89 marked this pull request as draft September 5, 2024 16:06
@clatapie
Copy link
Contributor Author

clatapie commented Sep 5, 2024

I can rework on it if docstring length is a priority. I already fixed some issues related in ansys/pyconverter-xml2py#222 but not all of them as you can see.
Except from this issue, feel free to comment any other change you would like me to work on.

Also, I had to comment the codespell pre-commit hook because it was failing even when I was ignoring the dedicated directory ``./src/ansys/mapdl/core/_commands). The next commit will show it.

@github-actions github-actions bot added CI/CD Related with CICD, Github Actions, etc examples Publishing PyMAPDL examples documentation Documentation related (improving, adding, etc) dependencies maintenance General maintenance of the repo (libraries, cicd, etc) labels Oct 18, 2024
@wiz-inc-572fc38784
Copy link
Contributor

wiz-inc-572fc38784 bot commented Oct 18, 2024

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities
Data Finding Sensitive Data
Secret Finding Secrets
IaC Misconfiguration IaC Misconfigurations
Total

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@clatapie clatapie force-pushed the feat/apdl_submodule branch from ac7b46a to 04dac45 Compare October 18, 2024 12:15
@github-actions github-actions bot removed CI/CD Related with CICD, Github Actions, etc examples Publishing PyMAPDL examples documentation Documentation related (improving, adding, etc) dependencies maintenance General maintenance of the repo (libraries, cicd, etc) labels Oct 18, 2024
@github-actions github-actions bot added the CI/CD Related with CICD, Github Actions, etc label Oct 18, 2024
Copy link
Member

@RobPasMue RobPasMue left a comment

Choose a reason for hiding this comment

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

Overall LGTM - couldn't really evaluate whether all the changes make sense or not but the logic seems properly done and the docstrings are really nicely formatted (for being autogenerated).

My concern is only about modules that have been renamed completely (take array_param to array_parameters. Maybe we should "keep" the old file, throw a warning saying that this module is deprecated, and import all the "new module" objects in this module (through a star import). But I'd only do this if users are frequently accessing the _commands subpackage directly... otherwise, let the Mapdl object handle it for them.

@github-actions github-actions bot added the examples Publishing PyMAPDL examples label Nov 28, 2024
@clatapie
Copy link
Contributor Author

Good point, thanks for reminding it @RobPasMue!
I will adjust the outdated files to follow the process you mentioned

@clatapie
Copy link
Contributor Author

Error with *TREAD.

Currently in PyMAPDL:

command = f"*TREAD,{par},{fname},{ext},,{nskip}"

With the auto-generated package:

command = f"*TREAD,{par},{fname},{ext},{nskip}"

Fixing this coma error might solve other failing tests as well.
This will be fixed in ansys/pyconverter-xml2py#356

@@ -33,7 +33,7 @@ env:
DPF_PORT: 21004
MAPDL_PACKAGE: ghcr.io/ansys/mapdl
ON_CI: True
PYTEST_ARGUMENTS: '-vvv -rxXsa --color=yes --durations=10 --random-order --random-order-bucket=class --maxfail=10 --reruns 3 --reruns-delay 4 --cov=ansys.mapdl.core --cov-report=html'
PYTEST_ARGUMENTS: '-vvv -rxXsa --color=yes --durations=10 --random-order --random-order-bucket=class --maxfail=100 --reruns 3 --reruns-delay 4 --cov=ansys.mapdl.core --cov-report=html'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be reverted once the tests will pass

@germa89
Copy link
Collaborator

germa89 commented Nov 28, 2024

@clatapie ... CICD is SUPER unstable right now since I merged #3268. I'm working on that.

I would probably revert that commit in the main_commands branch and see if the PR passes. To be safe, I would probably revert any other commit after since I'm working quite a lot on that at the moment.

@germa89
Copy link
Collaborator

germa89 commented Nov 28, 2024

Overall LGTM - couldn't really evaluate whether all the changes make sense or not but the logic seems properly done and the docstrings are really nicely formatted (for being autogenerated).

My concern is only about modules that have been renamed completely (take array_param to array_parameters. Maybe we should "keep" the old file, throw a warning saying that this module is deprecated, and import all the "new module" objects in this module (through a star import). But I'd only do this if users are frequently accessing the _commands subpackage directly... otherwise, let the Mapdl object handle it for them.

Users are not expected to access _commands by themselves, so any adjustment can be done in any of the Commands subclasses:

@clatapie
Copy link
Contributor Author

Thanks for your feedback @germa89.

The issue I found here is unrelated to the unit test stability. However, if after fixing it the error persists, I will remove the random argument.

You are right! Then, changes should already be in place as I manually modified src/ansys/mapdl/core/commands.py.

Copy link
Collaborator

@germa89 germa89 left a comment

Choose a reason for hiding this comment

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

Very good progress, this is looking great.

I would say there a few pain points we need to fix first before final merging.

  • Paragraphs in Notes are being merged into one.
  • Identations are wrong in some arguments (fname mainly)
  • we should decide what to do when the arguments descriptions are the same.
  • Many places have strange line lengths... like way too long... sometimes they have links.
  • the mkdir command is missing the argument
  • It seems bold format is not respected (it is always ignored)
  • *SET notes section is bad formatted, I think it is missing stuff.

Another things to consider:

  • For some reason the left side bar is not in alphabetical order:
image

(it did take a while this review... damn)

Comment on lines 59 to 64
# - repo: https://github.com/codespell-project/codespell
# rev: v2.3.0
# hooks:
# - id: codespell
# args: ["--toml", "pyproject.toml"]
# additional_dependencies: ["tomli"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why this was deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I commented it as explained in #3385 (comment)
I have planned to rework on it. For the moment, I don't know why the repository can not be ignored.

Comment on lines +18 to +21
Abbreviations.ucmd
Abbreviations.abbres
Abbreviations.abbr
Abbreviations.abbsav
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we are going to extend this commands on _MapdlCommandExtended class... shouldn't we use Mapdl or _MapdlCommandExtended instead of Abbreviations ??

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same for all the rest.

.. _ref_apdl:

<!-- vale off -->
Apdl
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think APDL should be all capital.

Comment on lines +7 to +30
<!-- vale on -->

.. list-table::

* - :ref:`ref_macro_files`
* - :ref:`ref_parameter_definition`
* - :ref:`ref_matrix_operations`
* - :ref:`ref_abbreviations`
* - :ref:`ref_process_controls`
* - :ref:`ref_array_parameters`
* - :ref:`ref_encryption_decryption`


.. toctree::
:maxdepth: 1
:hidden:

macro_files
parameter_definition
matrix_operations
abbreviations
process_controls
array_parameters
encryption_decryption
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is amazing.

examples/00-mapdl-examples/transient_thermal.py Outdated Show resolved Hide resolved
Comment on lines +777 to +778
\*TAXIS,longtable(1,4,1,1),2,1.0,2.2,3.5,4.7,5.9
``nAxis`` 2 (column location), starting at location 4.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing tex and newline.

Suggested change
\*TAXIS,longtable(1,4,1,1),2,1.0,2.2,3.5,4.7,5.9
``nAxis`` 2 (column location), starting at location 4.
\*TAXIS,longtable(1,4,1,1),2,1.0,2.2,3.5,4.7,5.9
would fill index values 1.0, 2.2, 3.5, 4.7, and 5.9 in ``nAxis`` 2 (column location), starting at location 4.

Assigns values to user-named parameters that may be substituted later
in the run. The equivalent (and recommended) format is
Reads data from a file and fills in an array parameter vector or matrix. Data are read from a
formatted file or, if the menu is off ( :ref:`menu` ,OFF) and ``Fname`` is blank, from the next input lines. The format of the data to be read must be input immediately following the :ref:`vread` command. The format specifies the number of fields to be read per record, the field width, and the placement of the decimal point (if none specified in the value). The read operation follows the available FORTRAN FORMAT conventions of the system (see your system FORTRAN manual). Any standard FORTRAN `real` format (such as (4F6.0), (E10.3,2X,D8.2), etc.) or alphanumeric format (A) may be used. Alphanumeric
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm puzzled with the line lengths.. they are so random...

Comment on lines +1222 to +1226
to (blank). A defined parameter must be deleted ( :ref:`starset` ) before its dimensions can be changed. Scalar (single valued) parameters should not be dimensioned. :ref:`dim` ,A,,3 defines a vector array with elements A(1), A(2), and A(3). :ref:`dim` ,B,,2,3 defines a 2x3 array with elements B(1,1), B(2,1), B(1,2), B(2,2), B(1,3), and B(2,3). Use :ref:`starstatus`, ``Par`` to display elements of array ``Par`` . You can write formatted data files (tabular formatting) from data held in arrays through the :ref:`vwrite` command.

If you use table parameters to define boundary conditions, then ``Var1``, ``Var2``, and/or ``Var3`` can either specify a primary variable (listed in ) or can be an independent parameter. If specifying an independent parameter, then you must define an additional table for the independent parameter. The additional table must have the same name as the independent parameter and may be a function of one or more primary variables or another independent parameter. All independent parameters must relate to a primary variable.

Tabular load arrays can be defined in both global Cartesian (default), cylindrical, spherical, or
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looong...

Comment on lines +88 to +93
def endif(self, **kwargs):
r"""Ends an if-then-else.
Mechanical APDL Command: `\*ENDIF <https://ansyshelp.ansys.com/Views/Secured/corp/v232/en//ans_cmd/Hlp_C_ENDIF.html>`_
Notes
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the future I would like to add bits here.. like how these commands are compared to the python ones.

-----
Optional intermediate block separator within an if-then-else construct. All seven characters of the
command name (\*ELSEIF) must be input. This command is similar to the :ref:`if` command except that
the ``Base`` field is not used. The :ref:`if`, :ref:`elseif`, :ref:`else`, and :ref:`endif`
Copy link
Collaborator

Choose a reason for hiding this comment

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

:ref:else is also taken from the python guide...

Copy link
Collaborator

Choose a reason for hiding this comment

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

You might need to go for :ref:ansys.mapdl.core.mapdl.MapdlBase.if or similar...

Copy link
Collaborator

Choose a reason for hiding this comment

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

(double check the above)

@germa89
Copy link
Collaborator

germa89 commented Nov 28, 2024

Error with *TREAD.

Currently in PyMAPDL:

command = f"*TREAD,{par},{fname},{ext},,{nskip}"

With the auto-generated package:

command = f"*TREAD,{par},{fname},{ext},{nskip}"

Fixing this coma error might solve other failing tests as well. This will be fixed in ansys/pyconverter-xml2py#356

Just double checking that the version with the empty argument is the correct one. :)

@RobPasMue
Copy link
Member

@germa89 - this PR should be "automated". I don't understand the reason to make local changes.

@clatapie
Copy link
Contributor Author

@germa89 's previous changes might be automatic since the branch is connected to feat/main_commands and not to the main one.

@github-actions github-actions bot removed the examples Publishing PyMAPDL examples label Dec 16, 2024
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 dependencies documentation Documentation related (improving, adding, etc) enhancement Improve any current implemented feature 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.

4 participants