[arvados] updated: 2.6.0-13-gd63d6ba64

git repository hosting git at public.arvados.org
Thu Apr 13 20:37:38 UTC 2023


Summary of changes:
 sdk/python/MANIFEST.in                             |  1 +
 {doc => sdk/python}/arvados-v1-discovery.json      |  0
 sdk/python/setup.py                                | 44 ++++++++++------------
 .../test/integration/discovery_document_test.rb    |  7 +++-
 4 files changed, 26 insertions(+), 26 deletions(-)
 rename {doc => sdk/python}/arvados-v1-discovery.json (100%)

       via  d63d6ba645b8e34cf9d248bd0407fab0b9ef6534 (commit)
      from  2690f3d6ca7700cc24b555ee926403235ebd9342 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit d63d6ba645b8e34cf9d248bd0407fab0b9ef6534
Author: Brett Smith <brett.smith at curii.com>
Date:   Thu Apr 13 16:36:10 2023 -0400

    18799: Move canonical discovery document to sdk/python
    
    The Python SDK build is currently the only code that needs it, and
    moving the file here simplifies the build implementation. We can
    reevaluate where it lives if another need arises.
    
    Arvados-DCO-1.1-Signed-off-by: Brett Smith <brett.smith at curii.com>

diff --git a/sdk/python/MANIFEST.in b/sdk/python/MANIFEST.in
index a624484dd..2dba5819e 100644
--- a/sdk/python/MANIFEST.in
+++ b/sdk/python/MANIFEST.in
@@ -4,5 +4,6 @@
 
 include LICENSE-2.0.txt
 include README.rst
+include arvados-v1-discovery.json
 include arvados_version.py
 include discovery2pydoc.py
diff --git a/doc/arvados-v1-discovery.json b/sdk/python/arvados-v1-discovery.json
similarity index 100%
rename from doc/arvados-v1-discovery.json
rename to sdk/python/arvados-v1-discovery.json
diff --git a/sdk/python/setup.py b/sdk/python/setup.py
index b03b650d6..66f1be730 100644
--- a/sdk/python/setup.py
+++ b/sdk/python/setup.py
@@ -34,8 +34,6 @@ class BuildDiscoveryPydoc(setuptools.Command):
 
     [1]: https://setuptools.pypa.io/en/latest/userguide/extension.html#setuptools.command.build.SubCommand
     """
-    DEFAULT_JSON_PATH = Path(SETUP_DIR, '..', '..', 'doc', 'arvados-v1-discovery.json')
-    DEFAULT_OUTPUT_PATH = Path('arvados', 'api_resources.py')
     NAME = 'discovery2pydoc'
     description = "build skeleton Python from the Arvados discovery document"
     editable_mode = False
@@ -46,31 +44,29 @@ class BuildDiscoveryPydoc(setuptools.Command):
 
     def initialize_options(self):
         self.build_lib = None
-        self.discovery_json = None
-        self.discovery_output = str(self.DEFAULT_OUTPUT_PATH)
+        self.discovery_json = 'arvados-v1-discovery.json'
+        self.discovery_output = str(Path('arvados', 'api_resources.py'))
+
+    def _relative_path(self, src, optname):
+        retval = Path(src)
+        if retval.is_absolute():
+            raise Exception("--{optname} should be a relative path")
+        else:
+            return retval
 
     def finalize_options(self):
         # Set self.build_lib to match whatever the build_py subcommand uses.
         self.set_undefined_options('build_py', ('build_lib', 'build_lib'))
-        if self.discovery_json is None and self.DEFAULT_JSON_PATH.exists():
-            self.discovery_json = str(self.DEFAULT_JSON_PATH)
-        out_path = Path(self.discovery_output)
-        if out_path.is_absolute():
-            raise Exception("--discovery-output should be a relative path")
-        else:
-            self.out_path = Path(self.build_lib, out_path)
+        self.json_path = self._relative_path(self.discovery_json, 'discovery-json')
+        self.out_path = Path(
+            self.build_lib,
+            self._relative_path(self.discovery_output, 'discovery-output'),
+        )
 
     def run(self):
         import discovery2pydoc
         self.mkpath(str(self.out_path.parent))
-        arglist = ['--output-file', str(self.out_path)]
-        if self.discovery_json is None:
-            print(
-                "warning: trying to load a live discovery document from configuration",
-                file=sys.stderr,
-            )
-        else:
-            arglist.append(self.discovery_json)
+        arglist = ['--output-file', str(self.out_path), str(self.json_path)]
         returncode = discovery2pydoc.main(arglist)
         if returncode != 0:
             raise Exception(f"discovery2pydoc exited {returncode}")
@@ -78,18 +74,16 @@ class BuildDiscoveryPydoc(setuptools.Command):
     def should_run(self):
         return True
 
-    # The protocol docs say that get_outputs should list *all* outputs, while
-    # get_output_mapping maps get_source_files to output file paths. Since we
-    # are generating files from outside the source tree, we should just return
-    # our output, with the source file list and output mapping both empty.
     def get_outputs(self):
         return [str(self.out_path)]
 
     def get_source_files(self):
-        return []
+        return [str(self.json_path)]
 
     def get_output_mapping(self):
-        return {}
+        return {
+            str(self.json_path): str(self.out_path),
+        }
 # Run discovery2pydoc as the first subcommand of build.
 distutils.command.build.build.sub_commands.insert(
     0, (BuildDiscoveryPydoc.NAME, BuildDiscoveryPydoc.should_run),
diff --git a/services/api/test/integration/discovery_document_test.rb b/services/api/test/integration/discovery_document_test.rb
index 672f52f7d..b592d6163 100644
--- a/services/api/test/integration/discovery_document_test.rb
+++ b/services/api/test/integration/discovery_document_test.rb
@@ -33,7 +33,12 @@ class DiscoveryDocumentTest < ActionDispatch::IntegrationTest
     assert(missing.empty?, "discovery document missing required fields")
 
     expected = JSON.pretty_generate(canonical)
-    src_path = Rails.root.join("../../doc/arvados-v1-discovery.json")
+    # Currently the Python SDK is the only component using this copy of the
+    # discovery document, and storing it with the source simplifies the build
+    # process, so it lives there. If another component wants to use it later,
+    # we might consider moving it to a more general subdirectory, but then the
+    # Python build process will need to be extended to accommodate that.
+    src_path = Rails.root.join("../../sdk/python/arvados-v1-discovery.json")
     begin
       actual = File.open(src_path) { |f| f.read }
     rescue Errno::ENOENT

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list