From 0d470471c6bb2916fa40d8a28ec69ee89d4256af Mon Sep 17 00:00:00 2001 From: Lazlo Westerhof Date: Wed, 11 Dec 2024 14:58:06 +0100 Subject: [PATCH] Fix API documentation workflow --- .../workflows/api-and-integration-tests.yml | 2 +- .github/workflows/api-documentation.yml | 8 ++--- tools/api/generate-openapi.py | 29 +++++++++++-------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.github/workflows/api-and-integration-tests.yml b/.github/workflows/api-and-integration-tests.yml index 37044bf0d..bee316ea1 100644 --- a/.github/workflows/api-and-integration-tests.yml +++ b/.github/workflows/api-and-integration-tests.yml @@ -76,7 +76,7 @@ jobs: run: | cd yoda/docker/compose docker exec provider.yoda sh -c 'set -x ; cd /etc/irods/yoda-ruleset && sudo chown irods:irods -R /etc/irods/yoda-ruleset && sudo -u irods git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" && sudo -u irods git pull && sudo -u irods git status' - docker exec provider.yoda sh -c "set -x ; cd /etc/irods/yoda-ruleset && sudo -u irods git checkout ${{ steps.extract_branch.outputs.branch }} && sudo -u irods python -m pip --no-cache-dir install --user -r /etc/irods/yoda-ruleset/requirements.txt && sudo -u irods make && sudo -u irods make install" + docker exec provider.yoda sh -c "set -x ; cd /etc/irods/yoda-ruleset && sudo -u irods git checkout ${{ steps.extract_branch.outputs.branch }} && sudo -u irods python3 -m pip --no-cache-dir install --user --break-system-packages -r /etc/irods/yoda-ruleset/requirements.txt && sudo -u irods make && sudo -u irods make install" docker exec provider.yoda sh -c "set -x ; sudo -u irods /var/lib/irods/irodsctl restart" - name: Pull and install latest version of portal diff --git a/.github/workflows/api-documentation.yml b/.github/workflows/api-documentation.yml index 80a3c1e3a..5e9337c5f 100644 --- a/.github/workflows/api-documentation.yml +++ b/.github/workflows/api-documentation.yml @@ -18,17 +18,15 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: [2.7] + python-version: [3.12] steps: - uses: actions/checkout@v4 - name: Set up Python - # setup-python stopped supporting Python 2.7, use https://github.com/MatteoH2O1999/setup-python - uses: MatteoH2O1999/setup-python@v3.2.1 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - allow-build: info - cache-build: true + architecture: x64 - name: Install dependencies run: | diff --git a/tools/api/generate-openapi.py b/tools/api/generate-openapi.py index b922b86e1..fe194ac85 100755 --- a/tools/api/generate-openapi.py +++ b/tools/api/generate-openapi.py @@ -12,24 +12,21 @@ This module imports (and therefore executes) ruleset code. Do not run it on untrusted codebases. """ -from __future__ import print_function __copyright__ = 'Copyright (c) 2020-2024, Utrecht University' __license__ = 'GPLv3, see LICENSE' -__author__ = ('Chris Smeele') -__author__ = ('Lazlo Westerhof') +__author__ = ('Chris Smeele') +__author__ = ('Lazlo Westerhof') # (in alphabetical order) -import sys -import re +import argparse import inspect import json - -from importlib import import_module +import re +import sys from collections import OrderedDict - -import argparse +from importlib import import_module parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('ruleset', metavar='RULESET', type=str, @@ -44,6 +41,7 @@ core = args.core module = args.module + # Strategy: Import the requested ruleset with an instrumented environment, and # apply introspection to extract API function information. @@ -55,9 +53,15 @@ class Sandbag(object): Used as a stub for various internal irods modules so that we can import rulesets without errors. """ - def __init__(self, *_, **kw): self._data = kw - def __call__(self, *_, **__): return Sandbag() - def __getattr__(self, k): return self._data.get(k, Sandbag()) + def __init__(self, *_, **kw): + self._data = kw + + def __call__(self, *_, **__): + return Sandbag() + + def __getattr__(self, k): + return self._data.get(k, Sandbag()) + def __setattr__(self, k, v): if k == '_data': return super(Sandbag, self).__setattr__(k, v) @@ -80,6 +84,7 @@ def f(g): return g return f + # Inject iRODS modules. sys.modules['irods_types'] = Sandbag() sys.modules['genquery'] = Sandbag()