Skip to content

Commit 4aaad46

Browse files
authored
Merge pull request OpenAssetIO#1342 from feltech/work/1324-stubCppPlugin
Add SimpleCppManager
2 parents f0c266f + 2e45034 commit 4aaad46

File tree

17 files changed

+1631
-23
lines changed

17 files changed

+1631
-23
lines changed

.github/workflows/integrations.yml

+33
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,36 @@ jobs:
193193
env:
194194
CMAKE_PREFIX_PATH: ${{ github.workspace }}/dist
195195
CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/.conan/conan_paths.cmake
196+
197+
# TODO(DF): SimpleCppManager should (also) be tested as part of
198+
# Python e2e tests, once we fix loading C++ plugins from Python.
199+
200+
- name: Build/install SimpleCppManager
201+
run: >
202+
${{ matrix.config.preamble }}
203+
204+
cd examples/manager/SimpleCppManager
205+
206+
cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
207+
-DOPENASSETIO_ENABLE_TESTS=ON
208+
-DOPENASSETIO_GLIBCXX_USE_CXX11_ABI=OFF
209+
210+
cmake --build build --parallel --config RelWithDebInfo
211+
212+
cmake --install build --prefix '${{ github.workspace }}/dist/plugins'
213+
--config RelWithDebInfo
214+
215+
env:
216+
CMAKE_PREFIX_PATH: ${{ github.workspace }}/dist
217+
218+
- name: Test SimpleCppManager with simpleResolver
219+
run: >
220+
python '${{ github.workspace }}/examples/host/simpleResolver/simpleResolver.py'
221+
openassetio-mediacreation:identity.DisplayName simplecpp://test/entity/1
222+
| grep 'Test Entity 1'
223+
224+
env:
225+
PYTHONPATH: ${{ github.workspace }}/dist/${{ matrix.config.site-packages }}
226+
OPENASSETIO_LOGGING_SEVERITY: 1
227+
OPENASSETIO_PLUGIN_PATH: ${{ github.workspace }}/dist/plugins
228+
OPENASSETIO_DEFAULT_CONFIG: ${{ github.workspace }}/examples/manager/SimpleCppManager/tests/resources/openassetio_config.toml

CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ cmake_dependent_option(
205205
OFF
206206
)
207207

208+
option(OPENASSETIO_ENABLE_SIMPLECPPMANAGER "Build the SimpleCppManager example" OFF)
209+
208210
# Enable clang-format formatting check.
209211
option(OPENASSETIO_ENABLE_CLANG_FORMAT "Enable clang-format check during build" OFF)
210212

@@ -339,11 +341,12 @@ if (OPENASSETIO_ENABLE_PYTHON)
339341
message(STATUS "Python relative install dir = ${OPENASSETIO_PYTHON_SITEDIR}")
340342
message(STATUS "Generate .pyi stubs = ${OPENASSETIO_ENABLE_PYTHON_STUBGEN}")
341343
endif ()
344+
message(STATUS "Build SimpleCppManager = ${OPENASSETIO_ENABLE_SIMPLECPPMANAGER}")
342345
message(STATUS "Create test targets = ${OPENASSETIO_ENABLE_TESTS}")
343346
if (OPENASSETIO_ENABLE_TESTS)
344347
message(STATUS "Create Python venv during tests = ${OPENASSETIO_ENABLE_PYTHON_TEST_VENV}")
345348
message(STATUS "Enable ABI diff check test = ${OPENASSETIO_ENABLE_TEST_ABI}")
346-
endif()
349+
endif ()
347350
message(STATUS "Warnings as errors = ${OPENASSETIO_WARNINGS_AS_ERRORS}")
348351
message(STATUS "Interprocedural optimization = ${OPENASSETIO_ENABLE_IPO}")
349352
message(STATUS "Enable PIC for static libs = ${OPENASSETIO_ENABLE_POSITION_INDEPENDENT_CODE}")
@@ -367,3 +370,7 @@ message(STATUS "Linter: cmake-lint = ${OPENASSETIO_ENABLE_CMAKE_
367370
# Recurse to library targets
368371

369372
add_subdirectory(src)
373+
374+
if (OPENASSETIO_ENABLE_SIMPLECPPMANAGER)
375+
add_subdirectory(examples/manager/SimpleCppManager)
376+
endif ()

CMakePresets.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"enable-tests"
3434
],
3535
"cacheVariables": {
36-
"OPENASSETIO_ENABLE_PYTHON_STUBGEN": "OFF"
36+
"OPENASSETIO_ENABLE_PYTHON_STUBGEN": "OFF",
37+
"OPENASSETIO_ENABLE_SIMPLECPPMANAGER": "OFF"
3738
}
3839
},
3940
{
@@ -104,7 +105,8 @@
104105
"hidden": true,
105106
"cacheVariables": {
106107
"OPENASSETIO_ENABLE_PYTHON": "ON",
107-
"OPENASSETIO_ENABLE_C": "ON"
108+
"OPENASSETIO_ENABLE_C": "ON",
109+
"OPENASSETIO_ENABLE_SIMPLECPPMANAGER": "ON"
108110
}
109111
},
110112
{

README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ workflows in content creation tooling.
99

1010
> - 👋 Come chat with us on [ASWF Slack](https://academysoftwarefdn.slack.com/archives/C03Q36QS8N4)
1111
> or our [mailing list](https://lists.aswf.io/g/openassetio-discussion).
12-
> - 🧰 Get started with the API [docs](https://openassetio.github.io/OpenAssetIO),
12+
> - 🧰 Get started with the [API docs](https://openassetio.github.io/OpenAssetIO),
1313
> Manager plugin [template](https://github.com/OpenAssetIO/Template-OpenAssetIO-Manager-Python),
14-
> [OpenAssetIO-MediaCreation](https://github.com/OpenAssetIO/OpenAssetIO-MediaCreation#readme)
14+
> and [MediaCreation](https://github.com/OpenAssetIO/OpenAssetIO-MediaCreation#readme)
1515
> for post-production workflows.
16-
> - 📖 Or see some examples: Ayon [manager plugin](https://github.com/ynput/ayon-openassetio-manager-plugin/tree/main#readme),
17-
> USD [Asset Resolver prototype](https://github.com/OpenAssetIO/usdOpenAssetIOResolver#readme),
18-
> OTIO [media linker](https://github.com/OpenAssetIO/otio-openassetio)
16+
> - 📖 Or see some [examples](examples/README.md) in the OpenAssetIO
17+
> ecosystem.
1918
> - 👀 You can follow the development effort [here](https://github.com/orgs/OpenAssetIO/projects/1/views/7)
2019
> and the longer term roadmap [here](ROADMAP.md).
2120
@@ -239,4 +238,4 @@ During this period, one may assume that the `x` above is synonymous with
239238
major version, and the `y` with minor version, for the purpose of
240239
compatibility. This means patch versions will be rolled into minor
241240
versions, but you may still consult the [release
242-
notes](./RELEASE_NOTES.md) for specific compatibility information.
241+
notes](./RELEASE_NOTES.md) for specific compatibility information.

RELEASE_NOTES.md

+10
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@ Release Notes
44
v1.0.0-beta.x.x
55
---------------
66

7+
### New Features
8+
9+
- Added SimpleCppManager - a minimal C++ manager and plugin example
10+
implementation, useful for testing C++ plugin support in hosts. This
11+
has minimal API support, so [Basic Asset Library (BAL)](https://github.com/OpenAssetIO/OpenAssetIO-Manager-BAL)
12+
should still be preferred as a test manager when Python is available.
13+
[#1324](https://github.com/OpenAssetIO/OpenAssetIO/issues/1324)
14+
715
### Improvements
816

917
- Added singular overload of `managementPolicy` for convenience.
1018
[#856](https://github.com/OpenAssetIO/OpenAssetIO/issues/856)
1119

20+
- Updated the `simpleResolver` example host to support C++ plugins.
21+
[#1324](https://github.com/OpenAssetIO/OpenAssetIO/issues/1324)
1222

1323
v1.0.0-beta.2.2
1424
---------------

cmake/ThirdParty.cmake

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ if (OPENASSETIO_ENABLE_PYTHON)
6868
# varying installation structures were used (eg GitHub Actions
6969
# runners).
7070
if (WIN32) # Should not use 'bin' for Windows
71-
set(OPENASSETIO_PYTHON_SITEDIR "Lib/site-packages")
71+
set(OPENASSETIO_PYTHON_SITEDIR "Lib/site-packages"
72+
CACHE STRING "Python site-packages directory" FORCE)
7273
else ()
7374
set(OPENASSETIO_PYTHON_SITEDIR
74-
"lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages")
75+
"lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages"
76+
CACHE STRING "Python site-packages directory" FORCE)
7577
endif ()
7678
endif ()
7779

examples/README.md

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Examples
2+
3+
There is an ever-growing list of example OpenAssetIO hosts and manager
4+
plugins. They cover a large range, including reference implementations,
5+
testing utilities, proof of concepts, and production integrations.
6+
7+
## This repository
8+
9+
In this repository you can find simple examples of host applications
10+
and manager plugins that make use of OpenAssetIO.
11+
12+
### Hosts
13+
14+
#### simpleResolver
15+
16+
The [simpleResolver](host/simpleResolver/README.md) is a Python
17+
command-line tool that can take an entity reference and a list of
18+
trait IDs, `resolve` them, and present the results as a dictionary
19+
in the terminal.
20+
21+
### Managers
22+
23+
#### SimpleCppManager
24+
25+
The [SimpleCppManager](manager/SimpleCppManager/README.md) is a C++
26+
OpenAssetIO manager plugin that provides functionality for a limited
27+
cross-section of the OpenAssetIO API. Its "database" of entities is
28+
taken directly from the settings provided by the host. It is designed to
29+
be used for testing C++ plugin support in host applications.
30+
31+
## Other OpenAssetIO projects
32+
33+
### Python manager plugin template
34+
35+
The [Python manager plugin template](https://github.com/OpenAssetIO/Template-OpenAssetIO-Manager-Python)
36+
provides a documentation-by-example implementation of a Python manager
37+
plugin.
38+
39+
### Jupyter notebooks
40+
41+
An ever-expanding collection of [Jupyter](https://jupyter.org/)
42+
notebooks is available as
43+
[examples in the MediaCreation](https://github.com/OpenAssetIO/OpenAssetIO-MediaCreation/tree/main/examples)
44+
repository. These demonstrate core OpenAssetIO concepts alongside the
45+
wider ecosystem, in particular as it relates to the VFX and media
46+
creation industry, through executable Python snippets. The pre-rendered
47+
notebooks can be viewed directly in GitHub, so downloading to execute
48+
locally is not required.
49+
50+
### Basic Asset Library
51+
52+
The [Basic Asset Library
53+
(BAL)](https://github.com/OpenAssetIO/OpenAssetIO-Manager-BAL) is a
54+
Python OpenAssetIO manager and plugin that is designed to enable host
55+
applications to test their integration against a wide spectrum of
56+
possible asset management system archetypes. It is designed to be fully
57+
puppetable, with responses controlled by a JSON configuration file. BAL
58+
is used extensively by the team for internal testing and demos of
59+
OpenAssetIO. Note that it is not intended as a reference implementation.
60+
61+
### USD Ar2 shim plugin
62+
63+
The [USD Asset Resolver plugin](https://github.com/OpenAssetIO/usdOpenAssetIOResolver#readme)
64+
allows OpenAssetIO plugins to be used within the USD ecosystem, by
65+
adapting the Ar2 API to the OpenAssetIO API.
66+
67+
### OpenTimelineIO media linker plugin
68+
69+
The [OTIO media linker](https://github.com/OpenAssetIO/otio-openassetio)
70+
plugin allows OpenAssetIO entity references to be recognised within
71+
OTIO documents, and resolved to their file path when the document is
72+
loaded.
73+
74+
## External projects
75+
76+
### Nuke
77+
78+
[Nuke](https://www.foundry.com/products/nuke-family/nuke) is the
79+
industry-leading commercial compositing tool by Foundry. As of
80+
version [15.1](https://campaigns.foundry.com/products/nuke-family/whats-new),
81+
Nuke has built-in support for OpenAssetIO as a headline feature.
82+
83+
### Ayon manager plugin
84+
85+
[Ayon by Ynput](https://ynput.io/ayon/) is an open source asset
86+
management system that forms part of Ynput's pipeline-as-service
87+
offering. Their
88+
[manager plugin](https://github.com/ynput/ayon-openassetio-manager-plugin)
89+
is available on GitHub.
90+
91+
### Blender OpenAssetIO demo script
92+
93+
[Blender](https://www.blender.org/) is an open source 3D digital content
94+
creation tool.
95+
96+
The [Blender relationships demo script](https://github.com/elliotcmorris/openassetio-relationships-blender)
97+
adds UI elements to Blender that allow a user to load external geometry
98+
from an asset management system, and pick alternative proxy
99+
representations of that geometry by querying OpenAssetIO entity
100+
relationships.

examples/host/simpleResolver/simpleResolver.py

+21-7
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@
2828
from openassetio.errors import BatchElementException
2929
from openassetio.access import ResolveAccess
3030
from openassetio.hostApi import HostInterface, ManagerFactory
31-
from openassetio.errors import ConfigurationException
31+
from openassetio.errors import ConfigurationException, OpenAssetIOException
3232
from openassetio.log import ConsoleLogger, SeverityFilter
33-
from openassetio.pluginSystem import PythonPluginSystemManagerImplementationFactory
33+
from openassetio.pluginSystem import (
34+
PythonPluginSystemManagerImplementationFactory,
35+
CppPluginSystemManagerImplementationFactory,
36+
)
3437

3538

3639
# pylint: disable=missing-function-docstring,no-self-use,invalid-name
@@ -147,20 +150,31 @@ def main():
147150
# used in standalone situations such as this.
148151
logger = SeverityFilter(ConsoleLogger())
149152

150-
# The Python plugin system can load manager implementations
151-
# defined outside of the API package.
152-
impl_factory = PythonPluginSystemManagerImplementationFactory(logger)
153-
154153
# The HostInterface implementation we supply that identifies
155154
# ourselves to the manager
156155
host_interface = SimpleResolverHostInterface()
157156

157+
# The C++ plugin system can load manager implementations
158+
# defined outside of the API package.
159+
impl_factory = CppPluginSystemManagerImplementationFactory(logger)
160+
158161
# Initialize the default manager as configured by $OPENASSETIO_DEFAULT_CONFIG
159162
# See: https://openassetio.github.io/OpenAssetIO/classopenassetio_1_1v1_1_1host_api_1_1_manager_factory.html#a8b6c44543faebcb1b441bbf63c064c76
160163
# All API/Manager messaging is channeled through the supplied logger.
161-
manager = ManagerFactory.defaultManagerForInterface(host_interface, impl_factory, logger)
164+
try:
165+
manager = ManagerFactory.defaultManagerForInterface(host_interface, impl_factory, logger)
166+
except OpenAssetIOException:
167+
# Exceptions occur when configuration exists, but loading the
168+
# config file or the plugin fails. E.g. if the config file
169+
# specifies the identifier of a Python plugin, but we tried to
170+
# locate and load a C++ plugin.
171+
# If a C++ plugin was not found, try the Python plugin system.
172+
impl_factory = PythonPluginSystemManagerImplementationFactory(logger)
173+
manager = ManagerFactory.defaultManagerForInterface(host_interface, impl_factory, logger)
162174

163175
if not manager:
176+
# Manager will be None only if OPENASSETIO_DEFAULT_CONFIG is
177+
# not set.
164178
raise ConfigurationException(
165179
"No default manager configured, "
166180
f"check ${ManagerFactory.kDefaultManagerConfigEnvVarName}"

examples/host/simpleResolver/test_simpleResolver.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434

3535
class Test_simpleResolver_errors:
36-
def test_when_lib_initialization_fails_then_error_written_to_stderr_and_return_code_non_zero(
36+
def test_when_no_config_then_error_written_to_stderr_and_return_code_non_zero(
3737
self, monkeypatch
3838
):
3939
monkeypatch.delenv("OPENASSETIO_DEFAULT_CONFIG", raising=False)
@@ -45,6 +45,18 @@ def test_when_lib_initialization_fails_then_error_written_to_stderr_and_return_c
4545
assert result.stderr.splitlines() == expected_message
4646
assert result.returncode == 1
4747

48+
def test_when_bad_config_then_error_written_to_stderr_and_return_code_non_zero(
49+
self, monkeypatch
50+
):
51+
monkeypatch.setenv("OPENASSETIO_DEFAULT_CONFIG", "/some/bad/path")
52+
result = execute_cli()
53+
expected_message = [
54+
"ERROR: Could not load default manager config from '/some/bad/path', file does not"
55+
" exist."
56+
]
57+
assert result.stderr.splitlines() == expected_message
58+
assert result.returncode == 1
59+
4860
def test_when_env_set_and_no_args_then_usage_printed_and_return_code_is_one(
4961
self, test_config_env # pylint: disable=unused-argument
5062
):

0 commit comments

Comments
 (0)