From 646080a337c0e8fdc23b4c59ad059390d9f60f67 Mon Sep 17 00:00:00 2001 From: weefuzzy Date: Wed, 19 Jan 2022 22:55:19 +0000 Subject: [PATCH 1/8] Make jinja rendering conditional on driver having a template --- flucoma/MakeRef.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/flucoma/MakeRef.py b/flucoma/MakeRef.py index 22c9009..585804d 100644 --- a/flucoma/MakeRef.py +++ b/flucoma/MakeRef.py @@ -85,15 +85,18 @@ def main(passed_args): ) ) for c in clients } + + if host_settings.get('template'): + for c in index: + render.client(c, index, args, host_settings) - for c in index: - render.client(c, index, args, host_settings) - - if host_settings['post']: host_settings['post'](index,args) + if host_settings.get('post'): + host_settings['post'](index,args) - topics = list(Path('topics/').resolve().glob('*.yaml')) - for t in topics: - render.topic(load_topic_data(t),index, args, host_settings) + if host_settings.get('topic_template'): + topics = list(Path('topics/').resolve().glob('*.yaml')) + for t in topics: + render.topic(load_topic_data(t),index, args, host_settings) if __name__ == '__main__': main(sys.argv[1:]) From 9ee8dde7a42c06d5f3b2b58d68f8870949a20d63 Mon Sep 17 00:00:00 2001 From: weefuzzy Date: Wed, 19 Jan 2022 22:56:45 +0000 Subject: [PATCH 2/8] minimal driver for raw JSON output --- flucoma/doc/raw/driver.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 flucoma/doc/raw/driver.py diff --git a/flucoma/doc/raw/driver.py b/flucoma/doc/raw/driver.py new file mode 100644 index 0000000..5ee2aa7 --- /dev/null +++ b/flucoma/doc/raw/driver.py @@ -0,0 +1,31 @@ +# Part of the Fluid Corpus Manipulation Project (http://www.flucoma.org/) +# Copyright 2017-2019 University of Huddersfield. +# Licensed under the BSD-3 License. +# See license.md file in the project root for full license information. +# This project has received funding from the European Research Council (ERC) +# under the European Union’s Horizon 2020 research and innovation programme +# (grant agreement No 725899). + +import json +from .. transformers import default_transform + +def transform_data(client, data): + return default_transform(client, data) + +def write_index(idx,program_args): + + path = program_args.output_path + path.mkdir(exist_ok=True) + apifile = path / 'flucoma.api.json' + with open(apifile,'w') as f: + json.dump(idx,f,sort_keys=True, indent=4) + + maxdb_objs = {'maxdb':{'externals':{}}} + +settings = { + 'glob': '**/*.json', + 'writer': FluidHTMLWriter, + 'transform': transform_data, + 'post': write_index, + 'defaults': None, +} From 0e970cb811e59e541ec41348e69c9302af254a45 Mon Sep 17 00:00:00 2001 From: weefuzzy Date: Wed, 19 Jan 2022 22:56:58 +0000 Subject: [PATCH 3/8] cmake target for raw JSON --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d4f13a..6e35431 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,6 +138,7 @@ add_ref_target(max "Making Max ref") add_ref_target(pd "Making PD ref") add_ref_target(cli "Making CLI ref") add_ref_target(sc "Making SC ref") +add_ref_target(raw "Making raw API JSON") enable_testing() From 4517ac2d11199eb84bdbc5bef6fe253f6a369ecb Mon Sep 17 00:00:00 2001 From: weefuzzy Date: Thu, 20 Jan 2022 13:14:37 +0000 Subject: [PATCH 4/8] fix cmake output directory --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e35431..09de51c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ set(MAX_DOC_OUT "${CMAKE_BINARY_DIR}/max_ref" CACHE PATH "") set(PD_DOC_OUT "${CMAKE_BINARY_DIR}/pd_ref" CACHE PATH "") set(CLI_DOC_OUT "${CMAKE_BINARY_DIR}/cli_ref" CACHE PATH "") set(SC_DOC_OUT "${CMAKE_BINARY_DIR}/sc_ref" CACHE PATH "") +set(RAW_DOC_OUT "${CMAKE_BINARY_DIR}" CACHE PATH "") # option(TESTS,"Run tests?") include(FetchContent) From 4607a5e1ad9862ab6e9b6ca9ebc5c77a79f6946e Mon Sep 17 00:00:00 2001 From: weefuzzy Date: Thu, 20 Jan 2022 13:14:48 +0000 Subject: [PATCH 5/8] add command line option for raw --- flucoma/MakeRef.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flucoma/MakeRef.py b/flucoma/MakeRef.py index 585804d..d104b0a 100644 --- a/flucoma/MakeRef.py +++ b/flucoma/MakeRef.py @@ -42,7 +42,7 @@ def main(passed_args): parser = argparse.ArgumentParser( description='Generate FluCoMa documentation for a given host, using input JSON and YAML data and a jinja template') - parser.add_argument('host', choices=['max','pd','cli','sc']) + parser.add_argument('host', choices=['max','pd','cli','sc','raw']) parser.add_argument('json_path', type=Path, help='Path to generated JSON client data') From 22aaece8d23d1282c17d43c060bc3aedd6ddd9cc Mon Sep 17 00:00:00 2001 From: weefuzzy Date: Thu, 20 Jan 2022 13:15:04 +0000 Subject: [PATCH 6/8] remove spurious item from raw driver --- flucoma/doc/raw/driver.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/flucoma/doc/raw/driver.py b/flucoma/doc/raw/driver.py index 5ee2aa7..9bcbc87 100644 --- a/flucoma/doc/raw/driver.py +++ b/flucoma/doc/raw/driver.py @@ -24,8 +24,7 @@ def write_index(idx,program_args): settings = { 'glob': '**/*.json', - 'writer': FluidHTMLWriter, - 'transform': transform_data, + 'transform': default_transform, 'post': write_index, 'defaults': None, } From cb27fc5ca8cf03591197c32e4d207f06e6079c88 Mon Sep 17 00:00:00 2001 From: James Bradbury Date: Mon, 28 Feb 2022 12:00:39 +0000 Subject: [PATCH 7/8] add back changes that dealt with conditional template rendering --- flucoma/MakeRef.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/flucoma/MakeRef.py b/flucoma/MakeRef.py index 720b16e..bbe07ba 100644 --- a/flucoma/MakeRef.py +++ b/flucoma/MakeRef.py @@ -42,7 +42,7 @@ def main(passed_args): parser = argparse.ArgumentParser( description='Generate FluCoMa documentation for a given host, using input JSON and YAML data and a jinja template') - parser.add_argument('host', choices=['max','pd','cli','sc']) + parser.add_argument('host', choices=['max','pd','cli','sc','raw']) parser.add_argument('json_path', type=Path, help='Path to generated JSON client data') @@ -84,16 +84,19 @@ def main(passed_args): **host_settings) ) ) for c in clients - } + } - for c in index: - render.client(c, index, args, host_settings) + if host_settings.get('template'): + for c in index: + render.client(c, index, args, host_settings) - if host_settings['post']: host_settings['post'](index,args) - - topics = list(Path('topics/').resolve().glob('*.yaml')) - for t in topics: - render.topic(load_topic_data(t),index, args, host_settings) + if host_settings['post']: + host_settings['post'](index,args) + + if host_settings.get('topic_template'): + topics = list(Path('topics/').resolve().glob('*.yaml')) + for t in topics: + render.topic(load_topic_data(t),index, args, host_settings) if __name__ == '__main__': main(sys.argv[1:]) From 1e2e017b44b487fb179d969288d8e63050ae2670 Mon Sep 17 00:00:00 2001 From: James Bradbury Date: Mon, 28 Feb 2022 12:00:54 +0000 Subject: [PATCH 8/8] add a github action for creating a basic API on actions --- .github/workflows/json_api.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/json_api.yml diff --git a/.github/workflows/json_api.yml b/.github/workflows/json_api.yml new file mode 100644 index 0000000..f7a321a --- /dev/null +++ b/.github/workflows/json_api.yml @@ -0,0 +1,33 @@ +name: Dev API + +on: + workflow_dispatch: + push: + branches: [ dev, ci/** ] + +jobs: + macbuild: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: flucoma/actions/env@v4 + - uses: flucoma/actions/docs@v4 + with: + target: 'MAKE_RAW_REF' + + - uses: dev-drprasad/delete-tag-and-release@v0.2.0 + with: + delete_release: true # default: false + tag_name: api # tag name to delete + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: package and upload + uses: softprops/action-gh-release@v1 + with: + name: FluCoMa Max Nightly Release + body: "This is a nightly build of the FluCoMa Max package. As such, be warned there may be bugs or other unexpected behaviour. The build hash is ${{ github.sha }}" + files: 'build/flucoma.api.json' + prerelease: false + tag_name: api + draft: false