You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ra...@apache.org on 2023/05/03 10:05:02 UTC

[arrow] branch main updated: MINOR: [Archery] Fixed ArrowSources.__str__() not returning string (#35386)

This is an automated email from the ASF dual-hosted git repository.

raulcd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new f794b208ce MINOR: [Archery] Fixed ArrowSources.__str__() not returning string (#35386)
f794b208ce is described below

commit f794b208ce70682f95bdce2339c4832c28045a4c
Author: Philip <ph...@gmail.com>
AuthorDate: Wed May 3 12:04:54 2023 +0200

    MINOR: [Archery] Fixed ArrowSources.__str__() not returning string (#35386)
    
    
    
    ### Rationale for this change
    
    When no git repository is initialised in the `arrow/` directory, archery is supposed to raise an error when executing for example `archery benchmark list`. This error raises another error because the class ArrowSources does not have a proper `__repr__()` method. Below an example traceback:
    ```sh
    Traceback (most recent call last):
      File "/opt/homebrew/bin/archery", line 33, in <module>
        sys.exit(load_entry_point('archery', 'console_scripts', 'archery')())
      File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
        return self.main(*args, **kwargs)
      File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1055, in main
        rv = self.invoke(ctx)
      File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 760, in invoke
        return __callback(*args, **kwargs)
      File "/opt/homebrew/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
        return f(get_current_context(), *args, **kwargs)
      File "/Users/philipgroet/projects/afstuderen/arrow/dev/archery/archery/cli.py", line 419, in benchmark_list
        runner_base = CppBenchmarkRunner.from_rev_or_path(
      File "/Users/philipgroet/projects/afstuderen/arrow/dev/archery/archery/benchmark/runner.py", line 222, in from_rev_or_path
        src_rev, _ = src.at_revision(rev_or_path, clone_dir)
      File "/Users/philipgroet/projects/afstuderen/arrow/dev/archery/archery/utils/source.py", line 151, in at_revision
        raise ValueError("{} is not backed by git".format(self))
    TypeError: __str__ returned non-string (type PosixPath)
    ```
    
    ### What changes are included in this PR?
    
    The `self.path` attribute of ArrowSources is of type Path, we stringify it.
    
    ### Are these changes tested?
    
    Yes, now prints: `ValueError: /Users/philipgroet/projects/afstuderen/arrow is not backed by git`
    
    ### Are there any user-facing changes?
    
    No, bugfix
    
    Authored-by: Philip Groet <ph...@gmail.com>
    Signed-off-by: Raúl Cumplido <ra...@gmail.com>
---
 dev/archery/archery/utils/source.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dev/archery/archery/utils/source.py b/dev/archery/archery/utils/source.py
index e8f0ca92c4..37d8cd502a 100644
--- a/dev/archery/archery/utils/source.py
+++ b/dev/archery/archery/utils/source.py
@@ -221,4 +221,4 @@ class ArrowSources:
         )
 
     def __repr__(self):
-        return self.path
+        return os.fspath(self.path)