Create a conda environment containing the provider software.
If no provider is specified, all providers will be installed.
If the provider is up to date or does not use a virtual environment, it will be skipped.
Source code in packages/climate-ref/src/climate_ref/cli/providers.py
| @app.command()
def create_env(
ctx: typer.Context,
provider: Annotated[
str | None,
typer.Option(help="Only install the environment for the named provider."),
] = None,
) -> None:
"""
Create a conda environment containing the provider software.
If no provider is specified, all providers will be installed.
If the provider is up to date or does not use a virtual environment, it will be skipped.
"""
config = ctx.obj.config
db = ctx.obj.database
providers = ProviderRegistry.build_from_config(config, db).providers
if provider is not None:
available = ", ".join([f'"{p.slug}"' for p in providers])
providers = [p for p in providers if p.slug == provider]
if not providers:
msg = f'Provider "{provider}" not available. Choose from: {available}'
logger.error(msg)
raise typer.Exit(code=1)
for provider_ in providers:
txt = f"virtual environment for provider {provider_.slug}"
if isinstance(provider_, CondaDiagnosticProvider):
logger.info(f"Creating {txt} in {provider_.env_path}")
provider_.create_env()
logger.info(f"Finished creating {txt}")
else:
logger.info(f"Skipping creating {txt} because it does use virtual environments.")
list_(ctx)
|