Skip to content

Conversation

tiran
Copy link
Contributor

@tiran tiran commented Apr 17, 2024

Changes

Which issue is resolved by this Pull Request:
Resolves #885

Description of your changes:

Use the working_dir of a repo object, not the repo object as base directory for globbing. Fixes:

  File "cli/utils.py", line 229, in get_documents
    for file_path in glob.glob(os.path.join(working_dir, pattern)):
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen posixpath>", line 76, in join
TypeError: expected str, bytes or os.PathLike object, not Repo

Replace the mock.patch with a proper spec-ed Mock that walks and talks like a git.Repo object. This makes the code easier to understand and does not violate the type annotations.

Use the `working_dir` of a repo object, not the repo object as base
directory for globbing. Fixes:

```
  File "cli/utils.py", line 229, in get_documents
    for file_path in glob.glob(os.path.join(working_dir, pattern)):
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen posixpath>", line 76, in join
TypeError: expected str, bytes or os.PathLike object, not Repo
```

Replace the mock.patch with a proper spec-ed Mock that walks and talks
like a `git.Repo` object. This makes the code easier to understand and
does not violate the type annotations.

Fixes: #885
Signed-off-by: Christian Heimes <cheimes@redhat.com>
@tiran tiran force-pushed the lab-generate-repo branch from 2dd58ec to e215dcc Compare April 17, 2024 20:11
Copy link
Contributor

@bjhargrave bjhargrave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better than #888.

@anik120 anik120 merged commit eff7fae into instructlab:main Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error loading temp directory documents after Git clone for knowledge
3 participants