Skip to content

Commit

Permalink
Update pythonVisualStudioCode.md
Browse files Browse the repository at this point in the history
Minor cleanup
  • Loading branch information
magnesj authored Mar 12, 2024
1 parent db53984 commit 7330877
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions _docs/pythonVisualStudioCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Python code is found in folder `\gitroot\ResInsight\GrpcInterface\Python\rips`.
To modify and test the Python API, an instance of ResInsight can be built and runned locally (e.g. using `Visual Studio`) or by running a released version from [https://resinsight.org/getting-started/download-and-install/](https://resinsight.org/getting-started/download-and-install/).

# Setting up virtual environment
The `rips` code can be run by creating a virtual environment, installing the `rips`-package into the virtual environment.
The `rips` code can be run by creating a virtual environment, installing the `rips` package into the virtual environment.
Using [`venv`](https://docs.python.org/3/library/venv.html) for Python and a local folder named `"ResInsightPythonScripts"`, the venv and python files
can be set up to test the `rips`-package.
can be set up to test the `rips` package.

With the following steps, the rips package is available in the venv named `ResInsightVenv`. A python file can be created, and usage of `rips`-package can be
With the following steps, the rips package is available in the venv named `ResInsightVenv`. A python file can be created, and usage of `rips` package can be
tested in the venv.

Note: If any missing packages occur, these can be installed in the venv using pip.
Expand All @@ -37,7 +37,7 @@ D:\ResInsightPythonScripts>".ResInsightVenv\Scripts\activate"
```

### For Ubuntu
The same steps can be done for Ubutu, providing the same folder, venv and `rips`-package install. VS Code can be utilized (for WSL distro if used from Windows) as for Windows in the `"Run and debug scripts"`-section below.
The same steps can be done for Ubutu, providing the same folder, venv and `rips` package install. VS Code can be utilized (for WSL distro if used from Windows) as for Windows in the `"Run and debug scripts"`-section below.

# Run and debug scripts
Open VS Code and select `"Open Folder..."`. Navigate to the `"ResInsightPythonScripts"`-folder.
Expand All @@ -50,7 +50,7 @@ Pushing `F1` and write `"Python: Select Interpreter"`, then navigate to the virt
![image](https://github.com/CeetronSolutions/resinsight-system-doc/assets/82032112/7dca545a-6bf3-4c58-9424-96bcde385c11)

### Create python script
Create a file for testing `rips`-packageWith a test file `my_python_file.py`. The file can be run by `python .\my_python_file.py`, or by using debug python code in Visual Studio Code.
Create a file for testing `rips` package with a test file `my_python_file.py`. The file can be run by `python .\my_python_file.py`, or by using Debug Python code in Visual Studio Code.

- A debugger for Python File can be customized by selecting `"create a launch.json file"`, and select `"Python File"` among Debug Configuration options:

Expand All @@ -59,11 +59,3 @@ Create a file for testing `rips`-packageWith a test file `my_python_file.py`. Th
- With a customized debugger, the test file can then be debugged with breakpoints in VS Code:

![image](https://github.com/CeetronSolutions/resinsight-system-doc/assets/82032112/042d1b5f-b5a9-4460-9497-afc6c5088f24)








0 comments on commit 7330877

Please sign in to comment.