Skip to content

feat: allow passing strings to the converter from the terminal - #3679

Merged
germa89 merged 14 commits into
mainfrom
feat/adding-passing-string-to-convert-cli
Jan 27, 2025
Merged

feat: allow passing strings to the converter from the terminal#3679
germa89 merged 14 commits into
mainfrom
feat/adding-passing-string-to-convert-cli

Conversation

@germa89

@germa89 germa89 commented Jan 20, 2025

Copy link
Copy Markdown
Collaborator

Description

As the title, so we can do:

This example demonstrates the main use of this tool:

$ pymapdl convert -f mapdl.dat -o python.py

If you omit the output argument, the converted code is shown on the screen.

You can use any option from ansys.mapdl.core.convert.convert_apdl_block function:

$ pymapdl convert -f mapdl.dat --auto-exit False
\"\"\"Script generated by ansys-mapdl-core version 0.69.dev0\"\"\"

from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(loglevel="WARNING", print_com=True, check_parameter_names=False)
mapdl.prep7()

mapdl.exit()

You can skip the imports, and the launching and exit calls if the option --only-code (-oc)
is given.

$ pymapdl convert -f mapdl.dat -oc
mapdl.prep7()

You can also pipe content from files o command line into the converter.

$ echo -ne "/prep7" | pymapdl convert -oc
mapdl.prep7()

$ echo -ne "/prep7" > my_file.inp
$ pymapdl convert -oc < my_file.inp
mapdl.prep7()

Issue linked

NA

Checklist

@germa89
germa89 requested a review from a team as a code owner January 20, 2025 13:32
@ansys-reviewer-bot

Copy link
Copy Markdown
Contributor

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

@ansys-reviewer-bot review

@germa89

germa89 commented Jan 20, 2025

Copy link
Copy Markdown
Collaborator Author

by the way, the pymapdl convert is veeeery slow.

@github-actions github-actions Bot added the new feature Request or proposal for a new feature label Jan 20, 2025
@codecov

codecov Bot commented Jan 20, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.13%. Comparing base (a2f91e6) to head (9c4e138).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3679      +/-   ##
==========================================
+ Coverage   87.88%   88.13%   +0.24%     
==========================================
  Files         187      187              
  Lines       14710    14697      -13     
==========================================
+ Hits        12928    12953      +25     
+ Misses       1782     1744      -38     

@github-actions github-actions Bot added the documentation Documentation related (improving, adding, etc) label Jan 20, 2025
@germa89 germa89 changed the title feat: allow passing raw strings to the converter feat: allow passing strings to the converter from the terminal Jan 20, 2025
@germa89

germa89 commented Jan 20, 2025

Copy link
Copy Markdown
Collaborator Author

Some timing:

on main

 hyperfine --warmup 3 --runs 5 'pytest -k pipe'
Benchmark 1: pytest -k pipe
  Time (mean ± σ):      5.864 s ±  0.123 s    [User: 2.532 s, System: 0.885 s]
  Range (min … max):    5.708 s …  5.986 s    5 runs

now

$ hyperfine --warmup 3 --runs 5 'pytest -k pipe'
Benchmark 1: pytest -k pipe
  Time (mean ± σ):      7.719 s ±  0.304 s    [User: 3.396 s, System: 1.164 s]
  Range (min … max):    7.314 s …  8.135 s    5 runs

the time difference is because now we do two tests instead of 1. Each one takes 2s, whereas in main it takes 1.95 aprox.

@germa89 germa89 self-assigned this Jan 20, 2025
@germa89

germa89 commented Jan 21, 2025

Copy link
Copy Markdown
Collaborator Author

@pyansys-ci-bot LGTM.

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

Copy link
Copy Markdown
Contributor

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

@germa89
germa89 merged commit 6060cab into main Jan 27, 2025
@germa89
germa89 deleted the feat/adding-passing-string-to-convert-cli branch January 27, 2025 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation related (improving, adding, 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