Skip to content

Commit 1aeceea

Browse files
authored
Merge pull request #2 from WebODM/docs
Add modern docs
2 parents 01143d9 + a84481e commit 1aeceea

16 files changed

Lines changed: 464 additions & 363 deletions

File tree

.github/workflows/docs.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Deploy docs
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.12"
27+
28+
- name: Install dependencies
29+
run: pip install -r docs/requirements.txt
30+
31+
- name: Build docs
32+
run: mkdocs build --strict
33+
34+
- name: Upload artifact
35+
uses: actions/upload-pages-artifact@v3
36+
with:
37+
path: site
38+
39+
deploy:
40+
needs: build
41+
runs-on: ubuntu-latest
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}
45+
steps:
46+
- name: Deploy to GitHub Pages
47+
id: deployment
48+
uses: actions/deploy-pages@v4

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PyODX
22

3-
For the latest documentation visit: https://pyodx.readthedocs.io
3+
For the latest documentation visit: https://pyodx.webodm.org
44

55
The information below is for managing the repository.
66

@@ -21,17 +21,13 @@ docker run -ti -p 3000:3000 webodm/nodeodx --test
2121
Make sure you are using Python 3.
2222

2323
```bash
24-
pip install virtualenv
25-
virtualenv -p venv
26-
source venv/bin/activate
27-
pip install -r requirements.txt
24+
pip install -r docs/requirements.txt
2825
```
2926

30-
Use [`sphinx-autobuild`](https://github.com/GaretJax/sphinx-autobuild) to automatically watch for changes and rebuild the html site using:
27+
Serve the docs locally with live reload:
3128

32-
```
33-
cd docs
34-
make livehtml
29+
```bash
30+
mkdocs serve
3531
```
3632

3733
To stop the server press `Ctrl+C`.

docs/CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pyodx.webodm.org

docs/Makefile

Lines changed: 0 additions & 22 deletions
This file was deleted.

docs/conf.py

Lines changed: 0 additions & 186 deletions
This file was deleted.

docs/examples.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Examples
2+
3+
## Get Node Info
4+
5+
Connect to a node and retrieve its information:
6+
7+
```python
8+
from pyodx import Node, exceptions
9+
10+
node = Node.from_url("http://localhost:3000?token=abc")
11+
12+
try:
13+
print(node.info())
14+
except exceptions.NodeConnectionError as e:
15+
print("Cannot connect: " + str(e))
16+
```
17+
18+
## Create a Task
19+
20+
Upload images, process them, and download results:
21+
22+
```python
23+
import os
24+
from pyodx import Node, exceptions
25+
26+
node = Node("localhost", 3000)
27+
28+
try:
29+
# Start a task
30+
print("Uploading images...")
31+
task = node.create_task(
32+
["images/image_1.jpg", "images/image_2.jpg"],
33+
{"dsm": True, "orthophoto-resolution": 4},
34+
)
35+
print(task.info())
36+
37+
try:
38+
# Block until the task is finished
39+
task.wait_for_completion()
40+
41+
print("Task completed, downloading results...")
42+
task.download_assets("./results")
43+
print("Assets saved in ./results (%s)" % os.listdir("./results"))
44+
45+
# Restart task and this time compute dtm
46+
task.restart({"dtm": True})
47+
task.wait_for_completion()
48+
49+
print("Task completed, downloading results...")
50+
task.download_assets("./results_with_dtm")
51+
print("Assets saved in ./results_with_dtm (%s)" % os.listdir("./results_with_dtm"))
52+
53+
except exceptions.TaskFailedError as e:
54+
print("\n".join(task.output()))
55+
56+
except exceptions.NodeConnectionError as e:
57+
print("Cannot connect: %s" % e)
58+
except exceptions.NodeResponseError as e:
59+
print("Error: %s" % e)
60+
```
61+
62+
## Upload Progress Callback
63+
64+
Track upload progress with a callback:
65+
66+
```python
67+
from pyodx import Node
68+
69+
node = Node("localhost", 3000)
70+
71+
def progress(percent):
72+
print("Upload: %.2f%%" % percent)
73+
74+
task = node.create_task(
75+
["image_1.jpg", "image_2.jpg"],
76+
progress_callback=progress,
77+
)
78+
```
79+
80+
## Task Status Callback
81+
82+
Monitor task status while waiting for completion:
83+
84+
```python
85+
from pyodx import Node
86+
87+
node = Node("localhost", 3000)
88+
89+
task = node.create_task(["image_1.jpg", "image_2.jpg"])
90+
91+
def status_update(info):
92+
print("Status: %s, Progress: %.1f%%" % (info.status, info.progress))
93+
94+
task.wait_for_completion(status_callback=status_update)
95+
```

0 commit comments

Comments
 (0)