-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial inclusion of python API docs * change workflow * rename to base.py for each module * update filter for generated docs for strings * quartoc module * move (un)register to addon.py * more API introduction stuff * canvas for scene and render management * add jupyter to docs requirements * source venv before quarto render * add oxdna docs * cleanup * rendering * add [all] to pyporoject * fix docs * move update_with_scene to entity * fixx render * Update docs.yml * Update docs.yml * maybe fix render * maybe fix render * maybe fix render * uv lock * proerly add jupyter and lock * pin python version * change to CPU rendering for GHA * tests * add back quartodoc * add IPython for tests * fix build docs * remove install of Blender for docs * add back uv setup * revamp docs layout for merge
- Loading branch information
1 parent
503ac42
commit ed432b6
Showing
39 changed files
with
3,731 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,20 +16,19 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: quarto-dev/quarto-actions/setup@v2 | ||
- name: Setup Blender | ||
uses: BradyAJohnston/setup-[email protected] | ||
- name: Install uv | ||
uses: astral-sh/setup-uv@v4 | ||
with: | ||
version: 4.2.5 | ||
- name: Install Packages | ||
run: | | ||
blender -b -P tests/python.py -- -m pip install -e ".[docs]" | ||
- name: Generate Docs | ||
run: | | ||
blender -b -P docs/generate.py | ||
version: "latest" | ||
|
||
- name: Render Docs | ||
run: quarto render docs | ||
|
||
run: | | ||
uv sync --all-extras | ||
cd docs | ||
uv run generate.py | ||
uv run quartodoc build | ||
cd .. | ||
uv run quarto render docs | ||
- name: Configure pull release name | ||
if: ${{github.event_name == 'pull_request'}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
title: Python API | ||
description: Introduction to the APi and the quirks of programming in Blender | ||
jupyter: python3 | ||
--- | ||
|
||
::: {.callout-warning} | ||
# The API is Unstable | ||
|
||
Molecular Nodes is designed and created first and foremost as an add-on for Blender, so the API can at times seem a bit quirky and for the time being is not to be considered stable. | ||
|
||
Molecular Nodes is versioned to match Blender versions, so while we are currently up to "4.2.*", the API should be not be consired to be that mature. | ||
::: | ||
|
||
This is how we can use the API. | ||
|
||
```{python} | ||
#| echo: false | ||
#| output: false | ||
import bpy | ||
bpy.ops.wm.read_homefile(app_template="") | ||
``` | ||
|
||
```{python} | ||
import molecularnodes as mn | ||
import numpy as np | ||
# we currently have to manually register a lot of the internals with Blender | ||
mn.register() | ||
mn.template.install() | ||
# create a 'Molecule' object, by fetching a structure and parsing it into the scene | ||
mol = mn.fetch("6N2Y", style = 'ribbon') | ||
``` | ||
|
||
## The Molecule Object | ||
|
||
The `Molecule` object has the original data, as well as the Blender object associated with. | ||
|
||
The different methods that are associated mostly interact with the Blender object, which is accessible via the `mol.object`, and the data is accessible via `mol.array`, which is the `biotite.AtomArrayStack` object. | ||
```{python} | ||
print(f"{len(mol)=}") | ||
print(f"{mol.object=}") | ||
print(f"{mol.array[0][:10]=}") | ||
``` | ||
|
||
```{python} | ||
mol.named_attribute('chain_id') | ||
``` | ||
|
||
```{python} | ||
mol.position | ||
``` | ||
|
||
### Updating the Atom Positions | ||
|
||
```{python} | ||
mol.position -= mol.centroid() | ||
mol.position | ||
``` | ||
|
||
```{python} | ||
canvas = mn.scene.Canvas() | ||
canvas.resolution = (720, 480) | ||
codes = ["4ozs", "8H1B", "8U8W"] | ||
styles = ['cartoon', 'ribbon', 'spheres'] | ||
materials = ['MN Ambient Occlusion', 'MN Default', 'MN Ambient Occlusion'] | ||
for code, style, material in zip(codes, styles, materials): | ||
canvas.scene_reset() | ||
canvas.render_engine = "CYCLES" | ||
canvas.samples_cycles = 32 | ||
# canvas.cycles_device = "GPU" | ||
canvas.cycles_device = "CPU" # can't do GPU rendering on GitHub actions | ||
mol = mn.fetch(code) | ||
mol.material = bpy.data.materials[material] | ||
mol.style = 'ribbon' | ||
canvas.frame_object(mol) | ||
mol.style = style | ||
canvas.snapshot() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
from .addon import register, unregister, _test_register | ||
from .entities import fetch, load_local | ||
from .addon import register, unregister | ||
from .entities import fetch, parse | ||
from . import color, blender | ||
|
||
try: | ||
from .scene import Canvas | ||
except ModuleNotFoundError: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from .utils import path_resolve | ||
from . import coll, nodes, mesh | ||
from . import mesh, coll, nodes, mesh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
from .ui import MN_OT_Import_Map, load | ||
from .mrc import MRC | ||
from .base import Density |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .density import Density | ||
from .base import Density | ||
|
||
import mrcfile | ||
from ...blender import coll, nodes | ||
|
Oops, something went wrong.