Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(search): search all repositories #9949

Merged
merged 7 commits into from
Jan 8, 2025

Conversation

abn
Copy link
Member

@abn abn commented Jan 5, 2025

Building on top of #9132, this change ensures that search command searches all non-explicit repositories configured for a project.

Resolves: #2446

Testing

Using pipx

pipx install --suffix=@9949 'poetry @ git+https://github.com/python-poetry/poetry.git@refs/pull/9949/head'

Using a container (podman | docker)

podman run --rm -i --entrypoint bash python:3.13 <<EOF
set -xe
python -m pip install --disable-pip-version-check -q git+https://github.com/python-poetry/poetry.git@refs/pull/9949/head
poetry new foobar
pushd foobar
poetry source add pytorch https://download.pytorch.org/whl/cu113
poetry search pytorch
EOF

Summary by Sourcery

Search all repositories configured for a project.

New Features:

  • Search across all repositories, rather than just PyPI.
  • Use tabular output format to improve readability of the search output.

Fixes:

  • Remove duplicates in search output.

Tests:

  • Added tests to verify that the search command searches across all repositories.

Docs:

  • Added notice regarding PyPI search being unavailable.

@abn abn added area/cli Related to the command line area/docs Documentation issues/improvements area/sources Releated to package sources/indexes/repositories labels Jan 5, 2025
@abn abn requested a review from a team January 5, 2025 21:21
Copy link

sourcery-ai bot commented Jan 5, 2025

Reviewer's Guide by Sourcery

This pull request changes the search command to search across all repositories configured for the project, rather than just PyPI. It also adds tests to verify the new functionality and updates the documentation to reflect the changes.

Sequence diagram for the updated search command flow

sequenceDiagram
    actor User
    participant CLI
    participant RepositoryPool
    participant Repository1
    participant Repository2

    User->>CLI: poetry search <tokens>
    activate CLI
    CLI->>RepositoryPool: search(tokens)
    activate RepositoryPool
    RepositoryPool->>Repository1: search(tokens)
    Repository1-->>RepositoryPool: results1
    RepositoryPool->>Repository2: search(tokens)
    Repository2-->>RepositoryPool: results2
    RepositoryPool-->>CLI: combined results
    deactivate RepositoryPool
    CLI->>CLI: deduplicate results
    CLI-->>User: display unique results
    deactivate CLI
Loading

Class diagram for the updated repository search functionality

classDiagram
    class AbstractRepository {
        <<abstract>>
        +search(query: str|list[str]): list[Package]
    }

    class Repository {
        +search(query: str|list[str]): list[Package]
    }

    class LegacyRepository {
        +search(query: str|list[str]): list[Package]
    }

    class PyPiRepository {
        +search(query: str|list[str]): list[Package]
    }

    class RepositoryPool {
        +search(query: str|list[str]): list[Package]
    }

    AbstractRepository <|-- Repository
    AbstractRepository <|-- LegacyRepository
    AbstractRepository <|-- PyPiRepository
    RepositoryPool o-- AbstractRepository

    note for AbstractRepository "Updated search method signature"
    note for RepositoryPool "Searches across all repositories"
Loading

File-Level Changes

Change Details Files
Updated the search command to search all repositories
  • Modified the search command to search across all repositories in the pool.
  • Added support for searching with multiple tokens.
  • Updated the search functionality in RepositoryPool, AbstractRepository, LegacyRepository, PyPiRepository, Repository, and HtmlLinkSource classes to accept a list of tokens or a single query string.
  • Added tests to verify that the search command searches across all repositories, including legacy repositories.
  • Added a fixture for a legacy repository.
  • Added tests to verify search behavior with both PyPI and legacy repositories, and with only a legacy repository.
  • Added a new legacy repository fixture file sqlalchemy-legacy.html.
  • Updated tests to reflect the changes in search behavior and include new test cases for searching with multiple repositories and tokens
src/poetry/console/commands/search.py
src/poetry/repositories/repository_pool.py
src/poetry/repositories/abstract_repository.py
src/poetry/repositories/legacy_repository.py
src/poetry/repositories/pypi_repository.py
src/poetry/repositories/repository.py
src/poetry/repositories/link_sources/html.py
tests/console/commands/test_search.py
Updated documentation
  • Added a note to the documentation about PyPI's search functionality changes and provided links to relevant resources.
  • Clarified that the search command now searches across all configured repositories, not just PyPI.
docs/cli.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @abn - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

tests/console/commands/test_search.py Outdated Show resolved Hide resolved
docs/cli.md Outdated Show resolved Hide resolved
@abn abn force-pushed the legacy-repo-search branch 2 times, most recently from 9b213c9 to b6d55e7 Compare January 5, 2025 22:02
@abn
Copy link
Member Author

abn commented Jan 5, 2025

@sourcery-ai review

@abn abn added the impact/docs Contains or requires documentation changes label Jan 5, 2025
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @abn - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

tests/console/commands/test_search.py Show resolved Hide resolved
Copy link

github-actions bot commented Jan 5, 2025

Deploy preview for website ready!

✅ Preview
https://website-9cz8z6bdy-python-poetry.vercel.app

Built with commit c6224c8.
This pull request is being automatically deployed with vercel-action

@abn abn mentioned this pull request Jan 5, 2025
3 tasks
@abn
Copy link
Member Author

abn commented Jan 5, 2025

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @abn - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

tests/console/commands/test_search.py Show resolved Hide resolved
@abn abn force-pushed the legacy-repo-search branch 2 times, most recently from ef6ad5e to b93cb20 Compare January 6, 2025 23:42
@abn abn requested a review from Secrus January 6, 2025 23:42
abn added 6 commits January 7, 2025 18:14
Building on top of python-poetry#9132, this change ensures that search command
searches all non-explicit repositories configured for a project.

Resolves: python-poetry#2446
This change converts the output of the `search` command to use a table
instead of unstructured output. Additionally, the output now also
includes source name.
@abn abn force-pushed the legacy-repo-search branch from b93cb20 to 7a7890f Compare January 7, 2025 17:14
@Secrus Secrus enabled auto-merge (squash) January 8, 2025 12:31
@Secrus Secrus merged commit 404aea5 into python-poetry:main Jan 8, 2025
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli Related to the command line area/docs Documentation issues/improvements area/sources Releated to package sources/indexes/repositories impact/docs Contains or requires documentation changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support search in LegacyRepository
2 participants