-
Notifications
You must be signed in to change notification settings - Fork 123
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
base: feat/main_commands
Are you sure you want to change the base?
feat: apdl
submodule
#3385
Conversation
Thanks for opening a Pull Request. If you want to perform a review write a comment saying: @ansys-reviewer-bot review |
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. |
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. Also, I had to comment the |
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension. |
ac7b46a
to
04dac45
Compare
Error with 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. |
@@ -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' |
There was a problem hiding this comment.
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
Users are not expected to access
|
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. |
There was a problem hiding this 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:
(it did take a while this review... damn)
.pre-commit-config.yaml
Outdated
# - repo: https://github.com/codespell-project/codespell | ||
# rev: v2.3.0 | ||
# hooks: | ||
# - id: codespell | ||
# args: ["--toml", "pyproject.toml"] | ||
# additional_dependencies: ["tomli"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this was deleted?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok... interesting.... Keep it like that until merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related: #3385 (comment)
Abbreviations.ucmd | ||
Abbreviations.abbres | ||
Abbreviations.abbr | ||
Abbreviations.abbsav |
There was a problem hiding this comment.
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
??
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok... So... if there are commands like input
which is "extended" (we change the behaviour to adapt to the diferent interfaces, or to adapt to python), we should probably not point to the docstring in the original code.
For instance, if we change the command ABBRES
to do something inside the function that might change the docstring, we should not point the documentation to Abbreviations.abbres
rather _MapdlCommandExtended.abbres
(assuming the new ABBRES
is coded in the _MapdlCommandExtended
class.
I think this is also related to: #3385 (comment)
But I think for the moment, we should not worry much, since most of the commands are not going to be expanded. Just a few, for instance input
which changes because of the gRPC interface. In that case, we might have both:
- the original MAPDL command in
run_controls.py
- the extended MAPDL command in
mapdl_grpc.py
, and this one will overwrite the docstring of the above.
What will happen when we search for input?... presumably two results will come up...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TLDR: Dont bother at the moment. We will figure out this in the future.
.. _ref_apdl: | ||
|
||
<!-- vale off --> | ||
Apdl |
There was a problem hiding this comment.
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.
\*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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing tex and newline.
\*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 |
There was a problem hiding this comment.
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...
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looong...
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 |
There was a problem hiding this comment.
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` |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(double check the above)
Just double checking that the version with the empty argument is the correct one. :) |
@germa89 - this PR should be "automated". I don't understand the reason to make local changes. |
@germa89 's previous changes might be automatic since the branch is connected to feat/main_commands and not to the |
…into feat/apdl_submodule
btw, this was fixed. CICD is "stable" again. |
For the commands with non-pythonic MAPDL commands (i.e. SECMODIF) where the MAPDL command signature might change depending on the argument: additional_arguments option@clatapie suggested an extra string argument such as: def secmodif(self, secid="", Keyword="", additional_arguments="", **kwargs):
# implementation
return self.run(f"SECMODIF,{secid}, {keyword},{additional_arguments}") So you can do: mapdl.secmodif(1, "NORM", "NX=2,NY=3, NZ=2, KCN=2") This effectively injects all the additional arguments as an string. CaveatsWhile this method might work, it delegates to the user all the responsability of building the command, and additionally it forces you to specify all the intermediate arguments (or commas). For instance if you only wants to use KCN, you will have to: mapdl.secmodif(1, "NORM", ", , , KCN=2") which looks rather weird. The
|
With respect to the arguments that have the same exact description, I will refer to the current discussion #3385 (comment) |
Answering @germa89's comment: additional_arguments option
mapdl.secmodif(1, "NORM", "2,3,2,2") Thus, This is due to the Python source code as reminded by @germa89: def secmodif(self, secid="", kywrd="", additional_arguments="", **kwargs):
# implementation
command = f"SECMODIF,{secid},{kywrd},{additional_arguments}"
return self.run(command) With previous example, command == SECMODIF,1,NORM,2,3,2,2 I agree the API is not ideal this way but it enables passing all the needed values.
|
My 2 cents... the problem with the |
I agree with your approach too @clatapie. The ROI seems low for now regarding the automation. It could even be difficult to maintain at first. |
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
draft
if it is not ready to be reviewed yet.feat: adding new MAPDL command
)