Skip to content

Commit

Permalink
WIP [Docs] Add docs on version workflows
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Cowland <[email protected]>
  • Loading branch information
foundrytom committed Nov 10, 2023
1 parent 5bbac62 commit 6d92457
Show file tree
Hide file tree
Showing 9 changed files with 758 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2023 The Foundry Visionmongers Ltd

name: Examples
on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-notebooks:
name: "Build Notebooks ${{ matrix.os }} python-${{ matrix.python }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["windows-latest", "ubuntu-latest", "macos-latest"]
python: ["3.7", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- run: |
python -m pip install .
python -m pip install -r examples/resources/requirements.txt
- name: Build Notebooks
run: jupyter nbconvert --to html --execute examples/versioning.ipynb
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.egg-info
.ipynb_checkpoints
29 changes: 29 additions & 0 deletions examples/resources/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import json

from IPython.display import display
from PIL import Image
from urllib.parse import urlparse, unquote

def print_traits_data(data):
"""
TraitsData objects arent readily convertable to a dict, or printable
at present. This is a little helper to aid the display of OpenAssetIO
data in the context of a notebook. It prints the traits and their
properties using pretty json formatting.
"""
as_dict = {
trait_id: {
property_key: data.getTraitProperty(trait_id, property_key)
for property_key in data.traitPropertyKeys(trait_id)
}
for trait_id in data.traitSet()
}
print(json.dumps(as_dict, indent=4, sort_keys=True))

def display_image(url):
"""
Displays an image in the notebook output.
"""
url_parts = urlparse(url)
image = Image.open(unquote(url_parts.path))
display(image)
5 changes: 5 additions & 0 deletions examples/resources/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
jupyter
openassetio>=v1.0.0b1rev0
openassetio-manager-bal>=v1.0.0a13
openassetio-mediacreation
Pillow
44 changes: 44 additions & 0 deletions examples/resources/versioning/bal_database.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"managementPolicy": {
"read": {
"default": {
"openassetio-mediacreation:managementPolicy.Managed": {},
"openassetio-mediacreation:content.LocatableContent": {}
}
},
"write": {
"default": {
"openassetio-mediacreation:managementPolicy.Managed": {},
"openassetio-mediacreation:content.LocatableContent": {}
}
}
},
"entities": {
"project_artwork/logos/openassetio": {
"versions": [
{
"traits": {
"openassetio-mediacreation:identity.DisplayName": {
"name": "The OpenAssetOI logo",
"qualifiedName": "logos / openassetio / v1"
},
"openassetio-mediacreation:content.LocatableContent": {
"location": "file:///${bal_library_dir}/logo.jpg"
}
}
},
{
"traits": {
"openassetio-mediacreation:identity.DisplayName": {
"name": "The OpenAssetIO logo",
"qualifiedName": "logos / openassetio / v2"
},
"openassetio-mediacreation:content.LocatableContent": {
"location": "file:///${bal_library_dir}/logo_revised.jpg"
}
}
}
]
}
}
}
Binary file added examples/resources/versioning/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/resources/versioning/logo_revised.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions examples/resources/versioning/openassetio_config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[manager]
identifier = "org.openassetio.examples.manager.bal"

[manager.settings]
library_path = "${config_dir}/bal_database.json"
Loading

0 comments on commit 6d92457

Please sign in to comment.