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: rpyc integration #859

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
291b55d
add dependencies and icon
dipinknair Apr 3, 2024
301bfd0
update makefiles
dipinknair Apr 3, 2024
9c348e5
update makefiles and add pdf download option
dipinknair Apr 3, 2024
544f605
Adding changelog entry: 679.added.md
pyansys-ci-bot Apr 3, 2024
6d129d3
check pdf generated
dipinknair Apr 3, 2024
c12be60
Merge branch 'feat/simple-pdf' of https://github.com/ansys/pymechanic…
dipinknair Apr 3, 2024
e579593
fix artifact name
dipinknair Apr 3, 2024
c14ba62
customize simple pdf
dipinknair Apr 3, 2024
c7a9adf
Merge branch 'main' into feat/simple-pdf
Revathyvenugopal162 Apr 4, 2024
bbb1c17
debug: check with pdf
Revathyvenugopal162 Apr 4, 2024
29b23e6
debug: check with latex
Revathyvenugopal162 Apr 4, 2024
73e9029
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 4, 2024
b00f430
debug: check with pdf
Revathyvenugopal162 Apr 4, 2024
903282c
Merge branch 'feat/simple-pdf' of https://github.com/ansys/pymechanic…
Revathyvenugopal162 Apr 4, 2024
77299e6
rpyc draft
dipinknair Aug 7, 2024
63502c8
rpyc depndencies
dipinknair Aug 7, 2024
d8d995e
Merge branch 'main' into feat/rpyc-integration
dipinknair Aug 7, 2024
c82980e
chore: adding changelog file 859.added.md
pyansys-ci-bot Aug 7, 2024
23c3768
Merge branch 'main' into feat/rpyc-integration
dipinknair Aug 9, 2024
7939aa2
keep general name
dipinknair Aug 9, 2024
8572077
add client wrapper
dipinknair Aug 12, 2024
e11a6c4
Merge branch 'main' into feat/rpyc-integration
dipinknair Aug 12, 2024
49d9ec3
restore mechanical.py
dipinknair Aug 12, 2024
4ed770d
Merge branch 'main' into feat/rpyc-integration
dipinknair Aug 13, 2024
3aa62bf
Merge branch 'main' into feat/rpyc-integration
dipinknair Sep 6, 2024
d239e05
Merge branch 'feat/rpyc-integration' of https://github.com/ansys/pyme…
dipinknair Oct 11, 2024
543af06
Merge branch 'main' into feat/rpyc-integration
dipinknair Oct 11, 2024
0acc4fb
chore: adding changelog file 859.added.md [dependabot-skip]
pyansys-ci-bot Oct 11, 2024
3d71f2f
Merge branch 'feat/rpyc-integration' of https://github.com/ansys/pyme…
dipinknair Oct 11, 2024
c61449e
kwargs added, property yet to install
dipinknair Nov 4, 2024
4e2d17d
property working
dipinknair Nov 11, 2024
bdba313
merge main
dipinknair Jan 10, 2025
1bec7a4
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jan 10, 2025
acc8507
merge main
dipinknair Jan 10, 2025
1267193
merge main
dipinknair Jan 10, 2025
a255341
Merge branch 'feat/rpyc-integration' of https://github.com/ansys/pyme…
dipinknair Jan 10, 2025
f04e0ad
Merge branch 'main' into feat/rpyc-integration
dipinknair Jan 13, 2025
c38f577
remote test passing
dipinknair Jan 17, 2025
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
360 changes: 163 additions & 197 deletions .github/workflows/ci_cd.yml

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ pdf:
cd $(BUILDDIR)/latex && latexmk -r latexmkrc -pdf *.tex -interaction=nonstopmode || true
(test -f $(BUILDDIR)/latex/*.pdf && echo pdf exists) || exit 1

# generate docs without examples
html-noplot:
@$(SPHINXBUILD) -D plot_gallery=0 -b html $(SOURCEDIR) $(BUILDDIR)/html $(SPHINXOPTS) $(O)
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
simple-pdf:
@$(SPHINXBUILD) -M simplepdf "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
(test -f $(BUILDDIR)/simplepdf/*.pdf && echo pdf exists) || exit 1
1 change: 1 addition & 0 deletions doc/changelog.d/679.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test: Add simple pdf for documentation
1 change: 1 addition & 0 deletions doc/changelog.d/859.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rpyc integration
9 changes: 9 additions & 0 deletions doc/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if "%1" == "" goto help
if "%1" == "html-noplot" goto html-noplot
if "%1" == "clean" goto clean
if "%1" == "pdf" goto pdf
if "%1" == "simple-pdf" goto simple-pdf
if "%1" == "linkcheck" goto linkcheck

%SPHINXBUILD% >NUL 2>NUL
Expand Down Expand Up @@ -52,6 +53,14 @@ if NOT EXIST ansys-mechanical-core.pdf (
exit /b 1)
Echo "pdf generated!"

:simple-pdf
%SPHINXBUILD% -M simplepdf %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
cd "%BUILDDIR%\simplepdf"
if NOT EXIST ansys-mechanical-core.pdf (
Echo "no pdf generated!"
exit /b 1)
Echo "pdf generated!"

:linkcheck
%SPHINXBUILD% -b %1 %SPHINXOPTS% %SOURCEDIR% %LINKCHECKDIR%
echo "Check finished. Report is in %LINKCHECKDIR%."
Expand Down
47 changes: 36 additions & 11 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
import os
import warnings

from ansys_sphinx_theme import ansys_favicon, get_version_match
from ansys_sphinx_theme import (
ansys_favicon,
ansys_logo_white,
ansys_logo_white_cropped,
get_version_match,
latex,
watermark,
)
from sphinx_gallery.sorting import FileNameSortKey

import ansys.mechanical.core as pymechanical
Expand Down Expand Up @@ -179,7 +186,7 @@
html_short_title = html_title = "PyMechanical"
html_theme = "ansys_sphinx_theme"
html_context = {
"github_user": "pyansys",
"github_user": "ansys",
"github_repo": "pymechanical",
"github_version": "main",
"doc_path": "doc/source",
Expand All @@ -206,7 +213,18 @@
"url": "https://github.com/ansys/pymechanical/discussions",
"icon": "fa fa-comment fa-fw",
},
{
"name": "Download documentation in PDF",
"url": f"https://{cname}/version/{get_version_match(version)}/_static/download/ansys.mechanical.core.pdf", # noqa: E501
"icon": "fa fa-file-pdf fa-fw",
},
],
"use_meilisearch": {
"api_key": os.getenv("MEILISEARCH_PUBLIC_API_KEY", ""),
"index_uids": {
f"pymechanical-v{get_version_match(version).replace('.', '-')}": "PyMechanical",
},
},
"cheatsheet": {
"file": "cheatsheet/cheat_sheet.qmd",
"title": "PyMechanical cheat sheet",
Expand All @@ -220,16 +238,9 @@
# Output file base name for HTML help builder.
htmlhelp_basename = "pymechanicaldoc"

html_sidebars = {
"changelog": [],
"examples/index": [],
"contributing": [],
}

html_show_sourcelink = False

latex_additional_files = [watermark, ansys_logo_white, ansys_logo_white_cropped]
# -- Options for LaTeX output ------------------------------------------------
latex_elements = {}
latex_elements = {"preamble": latex.generate_preamble(html_title)}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
Expand All @@ -244,6 +255,20 @@
),
]

# -- Options for simplepdf output --------------------------------------------
simplepdf_vars = {
"primary": "#000000",
"primary_opaque:": "#4D5352",
"secondary": "#3972A1",
"cover": "#ffffff",
"white": "#ffffff",
"links": "1E6DDC",
"cover-bg": "url(cover-bg.jpg) no-repeat center",
"cover-overlay": "rgba(200, 146, 17, 0.5)",
"top-left-content": "counter(page)",
"bottom-center-content": '"(c) ANSYS, Inc. All rights reserved"',
}


# -- Options for manual page output ------------------------------------------

Expand Down
43 changes: 43 additions & 0 deletions mod.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import ansys.mechanical.core as mech
from ansys.mechanical.core.embedding.rpc.utils import remote_method


# free functions: first argument of each must be app
def change_project_name(app: mech.App, name: str):
"""Change the project name of `app` to `name`."""
app.DataModel.Project.Name = name


def get_project_name(app: mech.App):
return app.DataModel.Project.Name


def get_model_name(app):
return app.Model.Name


# class: must be constructed using app
class ServiceMethods:
def __init__(self, app):
self._app = app

def __repr__(self):
return '"ServiceMethods instance"'

@remote_method
def get_model_name(self):
return self._app.Model.Name

def get_model_name_no_wrapper(self):
return self._app.Model.Name

@remote_method
def change_project_name(self, name: str):
self._app.DataModel.Project.Name = name

@remote_method
def get_project_name(self):
return self.helper_func()

def helper_func(self):
return self._app.DataModel.Project.Name
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,16 @@ doc = [
"sphinx-notfound-page==1.0.4",
"sphinxcontrib-websupport==2.0.0",
"sphinxemoji==0.3.1",
"sphinx-simplepdf==1.6.0"
]
viz = [
"ansys-tools-visualization-interface>=0.2.6",
"usd-core==24.11",
]
rpc = [
"rpyc==6.0.0",
"toolz==0.12.1",
]

[project.scripts]
ansys-mechanical = "ansys.mechanical.core.run:cli"
Expand Down
1 change: 1 addition & 0 deletions script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Model.Name
2 changes: 1 addition & 1 deletion src/ansys/mechanical/core/embedding/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def execute_script(self, script: str) -> typing.Any:
if script_result.Error is not None:
error_msg += f": {script_result.Error.Message}"
raise Exception(error_msg)
return script_result.Value
return str(script_result.Value)

def execute_script_from_file(self, file_path=None):
"""Execute the given script from file with the internal IronPython engine."""
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/mechanical/core/embedding/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _get_latest_default_version() -> int:
warnings.warn(
f"Multiple versions of Mechanical found! Using latest version {latest_version} ..."
)

print(latest_version)
return latest_version


Expand Down
35 changes: 35 additions & 0 deletions src/ansys/mechanical/core/embedding/rpc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (C) 2022 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""RPC and Mechanical service implementation."""
from .client import Client

# todo - provide an implementation of Server (RemoteMechancial) that installs the below
# from .default_server import RemoteMechanical
# and remove them from this import statement
from .misc import clear, run_python_script, run_python_script_from_file

# todo - combine Server and MechanicalService
from .server import MechanicalEmbeddedServer

# todo - get_remote_methods should not be here
from .utils import get_remote_methods, remote_method
Loading