コンテナでの開発#

This guide describes how to develop PyMAPDL features or fix bugs using a remote container. The files for setting up the container can be found in the .devcontainer directory.

MAPDLコンテナについて#

MAPDL ソフトウェアはオープンソースではないため、GPL ライセンスでは docker コンテナをユーザーに配布することはできません。MAPDL がインストールされた docker コンテナがあることが、このセクションで紹介する開発方法を利用するための必須条件です。独自の docker イメージを構築したい場合は、以下のリンクを参照してください 独自のMAPDL dockerコンテナを作成する

ライセンス#

前述のように、MAPDL を実行するには有効なライセンスが必要です。コンテナを起動すると、 script.sh ファイルが環境変数 ANSYSLMD_LICENSE_FILE が存在するかどうかを自動的にチェックします。この環境変数はライセンスサーバーのポートとIPアドレスを設定します。コンテナを起動する前にこの環境変数を設定していない場合は、ライセンスサーバーのポートとアドレスを入力するプロンプトが表示されます。

VS Codeを起動する前に、ターミナルから環境変数 ANSYSLMD_LICENSE_FILE を設定することができます。例えば、ライセンスサーバーのアドレスが 123.45.67.89 の場合、次のようにしてライセンスを設定します。

(.venv) PS C:\Users\user\pymapdl> $env:ANSYSLMD_LICENSE_FILE = '1055@123.45.65.89'
(.venv) PS C:\Users\user\pymapdl> code . # launch VS Code
(.venv) user@machine:~$ export ANSYSLMD_LICENSE_FILE =1055@123.45.65.89
(.venv) user@machine:~$code . # launch VS Code

そして Command palette を使ってコンテナ内のフォルダを開きます。

リモートコンテナで開発する#

注釈

This approach requires you have a Docker image with MAPDL installed. The Docker image listed in the repository development container configuration files is not for public use due to licensing issues. However, you can create your own Docker image <ref_make_container_> and use this file as a template for setting your own local development container.

To use a remote container, you must install this software:

As mentioned before, you must have your own Docker image with MAPDL installed locally available or hosted in an online registry, such as GitHub ghcr.io. For the purpose of this document, assume your image is hosted at ghcr.io/myaccount/mapdlimage:mytag.

You must then modify the docker-compose.yml file with your custom image:

ports:
   - '50052:50052'
   - '50055:50055'
image: 'ghcr.io/myaccount/mapdlimage:mytag'
user: "0:0"

警告

また、イメージの構成に合わせて環境変数やDockerオプションを変更する必要があるかもしれません。例えば、MAPDLコンテナがデフォルトのディレクトリにインストールされていない場合、環境変数 AWP_ROOT222 を変更する必要があるかもしれません。このような変更をPRでコミットしないように注意してください。

You can now open the current folder (or PyMAPDL repository) using ctr/cmd + shift + p to open the Visual Studio Code Command palette. Then select Dev Containers: Open Folder in Container. When you are prompted to select one of the multiple devcontainer configurations, select PyMAPDL-DevContainer (Local). Because the configuration is available in the .devcontainer/devcontainer-local directory, Visual Studio Code automatically launches the MAPDL container with the desired configuration.

注釈

初めてdevcontainerを起動したときは、準備が整うまで時間がかかるかもしれません。これは、コンテナ・イメージをレジストリから取得する必要があるためです。

You can now work normally, but you would be, in fact, working from inside the container. Because Visual Studio Code mount the local directory into the Docker container, you don't lose your changes if you accidentally delete your container. However, this mounting process might have a significant impact on the container performance, especially noticeable if you are using MacOS. You can avoid this by cloning the repository inside the container. For more information, see Quick start: Open a Git repository or GitHub PR in an isolated container volume.