Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
48 changes: 48 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy docs

on:
push:
branches: [master, main]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: pip install -r docs/requirements.txt

- name: Build docs
run: mkdocs build --strict

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: site

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PyODX

For the latest documentation visit: https://pyodx.readthedocs.io
For the latest documentation visit: https://pyodx.webodm.org

The information below is for managing the repository.

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

```bash
pip install virtualenv
virtualenv -p venv
source venv/bin/activate
pip install -r requirements.txt
pip install -r docs/requirements.txt
```

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

```
cd docs
make livehtml
```bash
mkdocs serve
```

To stop the server press `Ctrl+C`.
Expand Down
1 change: 1 addition & 0 deletions docs/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyodx.webodm.org
22 changes: 0 additions & 22 deletions docs/Makefile

This file was deleted.

186 changes: 0 additions & 186 deletions docs/conf.py

This file was deleted.

95 changes: 95 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Examples

## Get Node Info

Connect to a node and retrieve its information:

```python
from pyodx import Node, exceptions

node = Node.from_url("http://localhost:3000?token=abc")

try:
print(node.info())
except exceptions.NodeConnectionError as e:
print("Cannot connect: " + str(e))
```

## Create a Task

Upload images, process them, and download results:

```python
import os
from pyodx import Node, exceptions

node = Node("localhost", 3000)

try:
# Start a task
print("Uploading images...")
task = node.create_task(
["images/image_1.jpg", "images/image_2.jpg"],
{"dsm": True, "orthophoto-resolution": 4},
)
print(task.info())

try:
# Block until the task is finished
task.wait_for_completion()

print("Task completed, downloading results...")
task.download_assets("./results")
print("Assets saved in ./results (%s)" % os.listdir("./results"))

# Restart task and this time compute dtm
task.restart({"dtm": True})
task.wait_for_completion()

print("Task completed, downloading results...")
task.download_assets("./results_with_dtm")
print("Assets saved in ./results_with_dtm (%s)" % os.listdir("./results_with_dtm"))

except exceptions.TaskFailedError as e:
print("\n".join(task.output()))

except exceptions.NodeConnectionError as e:
print("Cannot connect: %s" % e)
except exceptions.NodeResponseError as e:
print("Error: %s" % e)
```

## Upload Progress Callback

Track upload progress with a callback:

```python
from pyodx import Node

node = Node("localhost", 3000)

def progress(percent):
print("Upload: %.2f%%" % percent)

task = node.create_task(
["image_1.jpg", "image_2.jpg"],
progress_callback=progress,
)
```

## Task Status Callback

Monitor task status while waiting for completion:

```python
from pyodx import Node

node = Node("localhost", 3000)

task = node.create_task(["image_1.jpg", "image_2.jpg"])

def status_update(info):
print("Status: %s, Progress: %.1f%%" % (info.status, info.progress))

task.wait_for_completion(status_callback=status_update)
```
Loading