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

refactor: annotate pymapdl part 1 #3569

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c6da515
refactor: annotating version file
germa89 Nov 22, 2024
a748ad1
refactor: annotate __init__
germa89 Nov 22, 2024
4338cb6
refactor: annotate commands.py
germa89 Nov 22, 2024
6030e93
refactor: annotate common_grpc.py
germa89 Nov 22, 2024
f3d2da6
refactor: annotate components.py
germa89 Nov 22, 2024
3187288
refactor: annotating convert.py
germa89 Nov 22, 2024
b3438b9
refactor: annotating errors.py
germa89 Nov 22, 2024
11dc3cb
refactor: annotate information.py
germa89 Nov 22, 2024
4d3feb8
refactor: annotate cli files
germa89 Nov 22, 2024
f66f866
refactor: annotate examples module
germa89 Nov 22, 2024
41faa59
chore: explain better a variable comment
germa89 Nov 22, 2024
0d04514
refactor: annotate inline_functions
germa89 Nov 22, 2024
442bea9
refactor: annotate jupyter.py
germa89 Nov 22, 2024
5dcb1b9
refactor: annotate krylov
germa89 Nov 22, 2024
70f194f
fix: missing imports
germa89 Nov 22, 2024
4430392
chore: adding changelog file 3569.added.md [dependabot-skip]
pyansys-ci-bot Nov 22, 2024
07fa38b
chore: update src/ansys/mapdl/core/cli/stop.py
germa89 Nov 22, 2024
6a067ed
fix: missing import
germa89 Nov 25, 2024
c2b339c
Merge branch 'refactor/annotate-files' of https://github.com/ansys/py…
germa89 Nov 25, 2024
65757f8
feat: add missing import
germa89 Nov 25, 2024
dc00676
fix: requests import
germa89 Nov 25, 2024
22af5cb
fix: missing import
germa89 Nov 25, 2024
1da1a7f
chore: merge remote-tracking branch 'origin/main' into refactor/annot…
germa89 Nov 25, 2024
78fabc2
fix: missing imports and wrong literal
germa89 Nov 25, 2024
60771c7
Merge branch 'main' into refactor/annotate-files
germa89 Nov 25, 2024
690e301
fix: test_detach_examples_submodule
germa89 Nov 25, 2024
c10f7f7
fix: pandas
germa89 Nov 25, 2024
d3547ab
Merge branch 'refactor/annotate-files' of https://github.com/ansys/py…
germa89 Nov 25, 2024
0568e10
test: testing examples
germa89 Nov 25, 2024
f3f8e96
fix: add missing import
germa89 Nov 25, 2024
0c15211
feat: fix pandas warning in docs. Also remove non-used function and a…
germa89 Nov 25, 2024
b8c40f2
fix: import
germa89 Nov 25, 2024
750308c
fix: import
germa89 Nov 25, 2024
9008021
Merge branch 'main' into refactor/annotate-files
germa89 Dec 10, 2024
b25ae57
Merge branch 'main' into refactor/annotate-files
germa89 Dec 13, 2024
2993179
ci: auto fixes from pre-commit.com hooks.
pre-commit-ci[bot] Dec 13, 2024
5204d70
Merge branch 'main' into refactor/annotate-files
germa89 Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/3569.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
refactor: annotate pymapdl part 1
15 changes: 8 additions & 7 deletions src/ansys/mapdl/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import importlib.metadata as importlib_metadata

###############################################################################
# Imports
# =======
Expand All @@ -40,17 +38,16 @@
#
from ansys.mapdl.core.logging import Logger

LOG = Logger(level=logging.ERROR, to_file=False, to_stdout=True)
LOG: Logger = Logger(level=logging.ERROR, to_file=False, to_stdout=True)
LOG.debug("Loaded logging module as LOG")

###############################################################################
# Globals
# =======
#
from ansys.mapdl.core._version import __version__
from ansys.mapdl.core.helpers import is_installed, run_every_import, run_first_time

__version__: str = importlib_metadata.version(__name__.replace(".", "-"))

# A dictionary relating PyMAPDL server versions with the unified install ones
VERSION_MAP: Dict[Tuple[int, int, int], str] = {
(0, 0, 0): "2020R2",
Expand All @@ -69,17 +66,21 @@

# Import related globals
_HAS_ATP: bool = is_installed("ansys.tools.path")
_HAS_CLICK: bool = is_installed("click")
_HAS_PIM: bool = is_installed("ansys.platform.instancemanagement")
_HAS_PANDAS: bool = is_installed("pandas")
_HAS_PYANSYS_REPORT: bool = is_installed("ansys.tools.report")
_HAS_PYVISTA: bool = is_installed("pyvista")
_HAS_REQUESTS: bool = is_installed("requests")
_HAS_TQDM: bool = is_installed("tqdm")
_HAS_VISUALIZER: bool = is_installed("ansys.tools.visualization_interface")


# Setup directories
USER_DATA_PATH: str = user_data_dir(appname="ansys_mapdl_core", appauthor="Ansys")
EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples")
EXAMPLES_PATH: str = os.path.join(USER_DATA_PATH, "examples")

# Store local ports
# Store ports occupied by local instances
_LOCAL_PORTS: List[int] = []

###############################################################################
Expand Down
11 changes: 4 additions & 7 deletions src/ansys/mapdl/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@
version_info = 0, 58, 'dev0'

"""

try:
import importlib.metadata as importlib_metadata
except ModuleNotFoundError: # pragma: no cover
import importlib_metadata
import importlib.metadata as importlib_metadata
from typing import Dict

# Read from the pyproject.toml
# major, minor, patch
__version__ = importlib_metadata.version("ansys-mapdl-core")
__version__: str = importlib_metadata.version("ansys-mapdl-core")

# In descending order
SUPPORTED_ANSYS_VERSIONS = {
SUPPORTED_ANSYS_VERSIONS: Dict[int, str] = {
252: "2025R2",
251: "2025R1",
242: "2024R2",
Expand Down
12 changes: 3 additions & 9 deletions src/ansys/mapdl/core/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,16 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

try:
import click

_HAS_CLICK = True

except ModuleNotFoundError:
_HAS_CLICK = False

from ansys.mapdl.core import _HAS_CLICK

if _HAS_CLICK:
###################################
# PyMAPDL CLI
import click

@click.group(invoke_without_command=True)
@click.pass_context
def main(ctx):
def main(ctx: click.Context):
pass

from ansys.mapdl.core.cli.convert import convert
Expand Down
7 changes: 4 additions & 3 deletions src/ansys/mapdl/core/cli/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
# SOFTWARE.

import os
from typing import Any, List

import click

_USING_PIPE = [False]
_USING_PIPE: List[bool] = [False]


def get_input_source(ctx, param, value):
def get_input_source(ctx: click.Context, param: Any, value: Any):
if not value and not click.get_text_stream("stdin").isatty():
_USING_PIPE[0] = True
return click.get_text_stream("stdin").read().strip()
Expand Down Expand Up @@ -180,7 +181,7 @@ def convert(
use_vtk: bool,
clear_at_start: bool,
check_parameter_names: bool,
):
) -> None:
"""Convert MAPDL code to PyMAPDL"""
from ansys.mapdl.core.convert import convert_apdl_block, convert_script

Expand Down
2 changes: 1 addition & 1 deletion src/ansys/mapdl/core/cli/list_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
default=False,
help="Print running location info.",
)
def list_instances(instances, long, cmd, location):
def list_instances(instances, long, cmd, location) -> None:
import psutil
from tabulate import tabulate

Expand Down
2 changes: 1 addition & 1 deletion src/ansys/mapdl/core/cli/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def start(
add_env_vars: Dict[str, str], # ignored
replace_env_vars: Dict[str, str], # ignored
version: Union[int, str],
):
) -> None:
from ansys.mapdl.core.launcher import launch_mapdl

if mode:
Expand Down
18 changes: 17 additions & 1 deletion src/ansys/mapdl/core/cli/stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from typing import Optional

import click


Expand Down Expand Up @@ -49,7 +51,21 @@
default=False,
help="Kill all MAPDL instances",
)
def stop(port, pid, all):
def stop(port: int, pid: Optional[int], all: bool) -> None:
"""Stop MAPDL instances running on a given port or with a given process id (PID).

This command stops MAPDL instances running on a given port or with a given process id (PID).
By default, it stops instances running on the port 50052.

Parameters
----------
port : int
Port where the MAPDL instance is running.
pid : Optional[int]
PID of the MAPDL instance
all : bool
If :class:`True`, kill all the instances regardless their port or PID.
"""
import psutil

from ansys.mapdl.core.launcher import is_ansys_process
Expand Down
Loading
Loading