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

only display unmet packages and env vars of the selected components #140

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 41 additions & 39 deletions ragna/_cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,54 +180,56 @@ def _select_components(

def _handle_unmet_requirements(components: Iterable[Type[Component]]) -> None:
unmet_requirements = set(
itertools.chain.from_iterable(
component.requirements() for component in components
)
requirement
for component in components
for requirement in component.requirements()
if not requirement.is_available()
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the actual fix. The diff below is just GH refusing to render it properly. There is no change below other than unindenting one level.

)
if not unmet_requirements:
return

if unmet_requirements:
rich.print(
"You have selected components, which have additional requirements that are"
"currently not met."
)
unmet_requirements_by_type = _split_requirements(unmet_requirements)
rich.print(
"You have selected components, which have additional requirements that are"
"currently not met."
)
unmet_requirements_by_type = _split_requirements(unmet_requirements)

unmet_package_requirements = sorted(
str(requirement)
for requirement in unmet_requirements_by_type[PackageRequirement]
unmet_package_requirements = sorted(
str(requirement)
for requirement in unmet_requirements_by_type[PackageRequirement]
)
if unmet_package_requirements:
rich.print(
"\nTo use the selected components, "
"you need to install the following packages: \n"
)
if unmet_package_requirements:
rich.print(
"\nTo use the selected components, "
"you need to install the following packages: \n"
)
for requirement in unmet_package_requirements:
rich.print(f"- {requirement}")
for requirement in unmet_package_requirements:
rich.print(f"- {requirement}")

rich.print(
f"\nTo do this, you can run\n\n"
f"$ pip install {' '.join(unmet_package_requirements)}\n\n"
f"Optionally, you can also install Ragna with all optional dependencies"
f"for the builtin components\n\n"
f"$ pip install 'ragna\[all]'"
)

unmet_env_var_requirements = sorted(
str(requirement)
for requirement in unmet_requirements_by_type[EnvVarRequirement]
rich.print(
f"\nTo do this, you can run\n\n"
f"$ pip install {' '.join(unmet_package_requirements)}\n\n"
f"Optionally, you can also install Ragna with all optional dependencies"
f"for the builtin components\n\n"
f"$ pip install 'ragna\[all]'"
)
if unmet_env_var_requirements:
rich.print(
"\nTo use the selected components, "
"you need to set the following environment variables: \n"
)
for requirement in unmet_env_var_requirements:
rich.print(f"- {requirement}")

unmet_env_var_requirements = sorted(
str(requirement)
for requirement in unmet_requirements_by_type[EnvVarRequirement]
)
if unmet_env_var_requirements:
rich.print(
"\nTip: You can check the availability of the requirements with "
"[bold]ragna check[/bold]."
"\nTo use the selected components, "
"you need to set the following environment variables: \n"
)
for requirement in unmet_env_var_requirements:
rich.print(f"- {requirement}")

rich.print(
"\nTip: You can check the availability of the requirements with "
"[bold]ragna check[/bold]."
)


def _wizard_common() -> Config:
Expand Down
Loading