Metadata-Version: 2.4
Name: anaconda-env-log
Version: 0.4.1
Summary: Log conda environments to Anaconda.cloud
License: BSD-3-Clause
Requires-Python: >=3.10
Requires-Dist: anaconda-anon-usage>=0.7.1
Requires-Dist: anaconda-auth>=0.14.0
Requires-Dist: anaconda-cli-base>=0.4
Requires-Dist: pydantic<3,>=2
Requires-Dist: typer
Provides-Extra: dev
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest-mock; extra == 'dev'
Requires-Dist: tox; extra == 'dev'
Requires-Dist: types-requests; extra == 'dev'
Provides-Extra: publish
Requires-Dist: build; extra == 'publish'
Requires-Dist: twine; extra == 'publish'
Requires-Dist: wheel; extra == 'publish'
Description-Content-Type: text/markdown

# anaconda-env-log

Log conda environments to anaconda.cloud

Once install, conda environment are automatically logged to anaconda.cloud when they are created or updated. This is accomplished with a pre-command conda plugin.


## Manual logging

Environment can be logged manually from the command line:

``` shell
conda env-log log {--name/-n/--prefix/-p name_or_prefix}
```

## Alerts

Environment are logged with an `alerts_enabled` flagged.

This can be set per environment from the command line:

``` shell
conda env-log alerts {--name/-n/--prefix/-p name_or_prefix} --enable/disable
```

The current alerts status can be checked using:

``` shell
conda env-log alerts {--name/-n/--prefix/-p name_or_prefix}
```

The `ANACONDA_ENV_LOG_ALERTS_ENABLED` environment variable controls the default alerts status for environments that do not set this explicitly. The default is False, meaning alerts are disabled.

## Configuration

By default, environment details are logged to anaconda.cloud.
This can be changed by setting the `ANACONDA_ENV_LOG_ACTION` environment variables.
Possible values for this variable include:

* `none` : Do not log anything.
* `print` : Print the recorded environment details to stdout.
* `local-dir` : Save the logs as JSON file in the directory specified by `ANACONDA_ENV_LOG_DIR`.
                If not specified logs are saved in $HOME/env_logs.
* `anaconda.cloud` : Log to anaconda.cloud, the default option.
                    This is accomplished using the `anaconda-cloud-auth` library which has it's
                    own set of variables for configuration.

These alternatives logging methods are intended for testing and debugging not production use.


## Setup for development

Ensure you have `conda` installed.
Then run:
```shell
make setup
```

This creates a development environment in the root of the project directory. Activate it using:
```shell
conda activate ./env
```

After activation `conda` will still refer to the install in the base environment. The `conda`
from the environment where plugin is installed needs to be called from the condabin directory:
``` shell
./env/condabin/conda env-log --help
```

To switch `conda` to refer to the developmennt installuse:
``` shell
eval $(./env/condabin/conda shell.zsh hook)
```

Replace `shell.zsh` with `shell.bash` when using bash.

With this switch `conda` can be used directory to test logging and the subcommand, for example:
``` shell
conda env-log --help
```

## Run the unit tests
```shell
make test
```

## Run the unit tests across isolated environments with tox
```shell
make tox
```
