Skip to content

Commit

Permalink
Release anaconda-client version 1.13.0 (#728)
Browse files Browse the repository at this point in the history
* Replace six import with direct import

* Replace six imports with direct imports

* Remove dead code

* Remove dead code: MultiPartIO

* Remove dead code: encode_multipart_formdata_stream

* Make import more explicit

* Remove unused function

* Update comment to reflect ownership of requests

* Remove unused type aliases

* Move down the __all__ definition

* Remove dependency on `six` library

* Ignore type error in optional import

* Specify miniconda-version

* xfail tests related to anaconda-project

* Use single-quotes for consistency

* Revert "xfail tests related to anaconda-project"

This reverts commit 3dc5194

* Revert "Remove unused type aliases"

This reverts commit 5de1eac.

* Revert "Remove unused function"

This reverts commit cafdc4c.

* Revert "Remove dead code: encode_multipart_formdata_stream"

This reverts commit 5cf23ab

* Revert "Remove dead code: MultiPartIO"

This reverts commit a1ee64a.

* Revert "Remove dead code"

This reverts commit 4219232.

* Add back removed function from __all__

* Replace six types with Python3 types from the six module

* Update the CHANGELOG.md

* Fix `make init` for local development

* Remove anaconda entrypoint

* Add a plugin to anaconda-cli-base

* Register main CLI as anaconda_cli.main plugin

* Don't mount login or logout at the top level if using the typer app

These are implemented inside anaconda-cloud-cli, which will delegate back to anaconda_client

* Remove "anaconda_cli.main" plugin

* Add descriptive docstring

* Move and rename some helper functions

* Tidy

* Add a docstring

* Refactor subcommand mounting into helper function

* In-line call to _get_help_text

* Rename constant

* Make deprecated text red and bold

* Fix type annotation

* Bump version and add anaconda-cli-base as dependency

* Remove entrypoint from recipe

* Use local path instead of git_url

* test cli plugin

* temporarily add anaconda-cloud/label/dev

* and in ci

* pylint

* mypy

* Remove RichHandler from root logger because of formatting conflict

* Satisfy the linter

* Ignore type hinting for optional import

* Revert change to version number

Save this for the release

* Use anaconda-cloud channel instead of the dev label

* xfail tests related to anaconda-project

(cherry picked from commit 3dc5194)

* Exclude anaconda-project from extras

* Bump dependency on anaconda-cli-base

* Make quotes consistent

* Add anaconda-project back to extras just to be completely safe

* Fix line ending

* Update setup.py

* Remove duplicate import

It looks like a merge issue caused a duplication of code in `binstar_client.utils.config`.

* Updated links in upload help text (#714)

* Updated links in upload help text

I noticed that when running `anaconda upload --help` it would print out a bit of reStructuredText instead of plain output. Turns out it was hardcoded in the docstring of the `upload` command module.

Also fixed the URLs of the links.

* Fix linter by ignoring error in docstring line being too long

---------

Co-authored-by: mattkram <[email protected]>

* Raise error on deprecated `notebook` subcommand (#722)

* Replace parser for notebook command to print an error message and exit

* Remove dead code from notebooks.py

* Cleanup

* Remove NOTES.md

* Update documentation to remove references to notebooks in download.py

We do this because the download command actually works for packages,
so if we want to remove that we need to do it more gradually/gracefully.

* Remove unreachable code

We can never download notebooks with an embedded environment.

* Update actions/upload-artifact to v4

* Ignore local dev conda environment

* Ignore more coverage files (which can have a suffix)

* Remove upload notebook from the help text

* Print error message when attempting to upload a notebook

* Remove broken test due to removal of notebook upload functionality

* Remove unused import

* Use conda package streaming (#724)

* inspect info/ dir without temporary files

* open archive in 'rb' mode

* remove unnecessary fileobj parameter

* replace data_dir test utility

* remove spurious import

* format with blue

* reduce diff

* use frozenset as default parameter

* handle tested icon filename case

* define icon_b64

* lint 2

* test without lint

* annotations

* lint

* mypy lints

* silly style

* check Image type without assert

* remove type: ignore from ImportError

* Remove duplicate import and clean up formatting slightly

* Restore test dependency on lint

* Rempve duplicate line

The duplicate application of pop was causing issues in that the first
invocation removed the item looked for the second time

---------

Co-authored-by: mattkram <[email protected]>

* chore: Remove logging hack (#725)

* feat: Add optional `typer` subcommands (#723)

* Bump version number
* Update the CHANGELOG.md
* Fix bug: Manually handle sys.argv to allow proper handling of all CLI options and args
* Use pytest-mock to spy calls to binstar_main and ensure arguments are processed correctly
* Add test to ensure top-level CLI options are passed through to binstar_main.
* Fix whitespace linting errors
* Satisfy pycodestyle, pylint, and mypy
* Exclude conda environment and coverage report
* Implement way to optionally define a new subcommand using typer
* Pass the common args via ctx.obj
* Remove commented context_settings from main callback
* This allows token to be passed either before or after "org" subcommand
* Depend on upcoming changes to anaconda-cli-base
* Remove debug statement
* Start work on upload subcommand
* Start mapping arguments for upload subcommand, enhance tests
* Copy in defaults for Namespace and tests
* Refactor the test to be parametrized
* Add more tests around label and no-progress args
* Extend testing for multiple label options
* Add test and handling for deprecated --channel option
* Add -u/--user option
* Add parametrization to test with and without org prefix
* Add keep_basename option
* Add package option
* Add support for package version option
* Add support for package summary option
* Add support for package_type option
* Add support for description option
* Add support for thumbnail
* Add support for private
* Add support for register/auto_register
* Fix interactive flag
* Add fail option
* Add force option
* Add handling of mutually-exclusive options
* Fix the exclusivity callback to handle False values
* Add skip-existing option
* Add force-metadata-update option
* Add build-id option
* Add note about --json-help option
* Add testing around top-level options too
* Show help if no args provided
* Clean up help text
* Files are required
* Don't exit on first failed test
* Move test up
* Start adding copy command
* Add to_owner option
* Add from-label and to-label options
* Add replace and update options
* Parse spec instead of using raw string
* Add new subcommand for move
* Support token and site options in copy
* Start creating channel and label subcommands
* Add test for organization option
* Add handling of --copy option
* Add handling of --list option
* Add handling of --show option
* Add handling of --lock and --unlock options
* Add handling of --remove option
* Start adding exclusivity to the actions
* Finish adding exclusivity to the actions
* Add handling of required exclusive option group
* Parametrize command name
* Renamed from ctx.obj to ctx.obj.params
* Start adding update subcommand
* Add tests for --token and --site
* Add package_type option
* Add --release option
* Add search subcommand
* Select --platform from a list of choices
* Add boilerplate for new groups subcommand definition
* Add handling of action argument
* Add group spec argument
* Add --perms option
* Clean up imports
* Add new show subcommand
* Start implementing remove subcommand
* Add --force option
* Start adding auth subcommand
* Add default handling of token name, and tests
* Add --organization option
* Add flag-like options
* Add --remove option
* Add handling of required and mutually exclusive action options
* Add handling of token strength options
* Add --url option
* Add --max-age option
* Add --scopes option
* Add the --out option
* Add basic boilerplate for config subcommand
* Improve handling of type option
* Add --set option
* Add --get option
* Add --remove option
* Add flag options --show, --files, --show-sources
* Add --user and --system options
* Add boilerplate for package command
* Add required spec argument
* Add default values
* Add actions flags
* Add required exclusive option callback
* Fix test
* Add options for --summary, --license, --license-url
* Add options for --private and --personal
* Move all mount_subcommand functions to bottom of modules
* Alphabetize import
* Add a new test and fixture that runs each CLI entrypoint combination the same and checks the arg parsing
* Move sys.argv monkeypatch to fixture
* Extend fixture to cover with and without "org" prefix
* Refactor mocking into an encapsulating class
* Move fixture to top and refactor package command test
* Add fixture IDs and use assertion methods for better comparison output
* Use new fixture and fix a bug!
* Refactor copy and move commands
* Migrate update command and get parity
* Migrate search command and get parity
* Migrate channel/label command and get parity
* Migrate groups command and get parity
* Migrate show command and get parity
* Migrate remove command and get parity
* Migrate auth command and get parity with TODO
* Migrate config command and get parity with TODO
* Fix whitespace and line-too-long issues
* Ignore bandit alerts for test TOKEN values
* Update imports to use typing_extensions
* Fix type hints
* Resolve type errors in config.py
* Fix types in channel.py
* Fix tests by moving class definition above usage as type
* Fix types in authorizations.py
* Format code
* Fix pylint errors
* Remove intermediate callback function (we get args from parent)
* Remove unused imports
* Fix comment syntax
* Bump dependency to anaconda-cli-base>=0.4.0
* Try to set _TYPER_FORCE_DISABLE_TERMINAL
* Fix python 3.8 type to use typing.List

* Bump version number

* Update the CHANGELOG.md

* Re-order list and add PR 724

* Add CHANGELOG entry for #724

* Generate noarch package when developing locally

* Revert "feat: Add optional `typer` subcommands (#723)"

This reverts commit d734167.

* Update CHANGELOG for reverted commit

* Update conda.recipe/meta.yaml

* Add minimum version for conda-package-streaming

* Add note to parameter help description for --keep-basename (#727)

* Add test to cover parse_specs (#729)

* Add test for parse_specs to attempt to reproduce

* chore: lint

* Rename file and add a comment

* Change username

* Add failing test

* Enable both -h and --help options

* Remove trailing whitespace

* Use a callback to prevent recursively adding typer to every subcommand

* Show non-deprecated subcommands on main help screen, deprecate channel

* Remove unneeded assertions

We've removed these prefixes from the help text

* Clean up and update CHANGELOG

* Update the help text to be more generic

* Update minimum version of anaconda-cli-base

---------

Co-authored-by: Albert DeFusco <[email protected]>
Co-authored-by: Michael C. Grant <[email protected]>
Co-authored-by: Jannis Leidel <[email protected]>
Co-authored-by: Daniel Holth <[email protected]>
  • Loading branch information
5 people authored Nov 1, 2024
1 parent f2d1601 commit 0899200
Show file tree
Hide file tree
Showing 29 changed files with 606 additions and 277 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/check-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ jobs:
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
miniconda-version: "latest"

- name: Install latest conda
run: |
conda update -n base -q conda
- name: Install dependencies
run: |
conda install python=${{ matrix.python-version }} pip --file requirements.txt --file requirements-extra.txt
conda install -c defaults -c anaconda-cloud python=${{ matrix.python-version }} pip --file requirements.txt --file requirements-extra.txt
pip install -r requirements-dev.txt
python setup.py develop --no-deps
Expand Down Expand Up @@ -79,7 +80,7 @@ jobs:
- name: Export reports
if: ${{ always() && steps.conda_environment_information.outputs.exit_status == 'success' }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: report-lint-${{ matrix.python-version }}-${{ matrix.os }}
path: .artifacts/reports
Expand All @@ -100,21 +101,22 @@ jobs:
# unfortunately, as of June 2021 - GitHub doesn't support anchors for action scripts

- name: Checkout project
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
miniconda-version: "latest"

- name: Install latest conda
run: |
conda update -n base -q conda
- name: Install dependencies
run: |
conda install python=${{ matrix.python-version }} pip --file requirements.txt --file requirements-extra.txt
conda install -c defaults -c anaconda-cloud python=${{ matrix.python-version }} pip --file requirements.txt --file requirements-extra.txt
pip install -r requirements-dev.txt
python setup.py develop --no-deps
Expand All @@ -132,7 +134,7 @@ jobs:
- name: Export reports
if: ${{ always() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: report-test-${{ matrix.python-version }}-${{ matrix.os }}
path: .artifacts/reports
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pip-log.txt
# Unit test / coverage reports
.coveragerc
.coverage
.coverage.*
.tox
nosetests.xml

Expand All @@ -48,3 +49,6 @@ __conda_*__.txt

# Additional files
/.artifacts/

# Local dev environment
env/
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,41 @@

We [keep a changelog.](http://keepachangelog.com/)

## 1.13.0

As part of extending our CLI, we have been migrating to a plugin-based system.
This release removes the `anaconda` entrypoint from `anaconda-client`, which is now located instead in `anaconda-cli-base`.
When these changes are installed, we don't intend any breaking behavior for the user.

Any changes are generally dependent on the presence of other Anaconda CLI plugins.
In the case that another plugin is installed (like `anaconda-cloud-auth`), the following changes may be observed:

* All existing `anaconda-client` subcommands are available
* All existing `anaconda-client` subcommands are ALSO available with the `org` prefix, e.g. `anaconda org upload`.
It is recommended to adopt this format, as it is more explicit.
* The help text will be modified (i.e. type `anaconda`).
Not all `anaconda-client` subcommands will be shown.
* The `anaconda notebooks` subcommand will explicitly be listed as deprecated in the CLI help.

In order to maintain backwards compatibility for all subcommands, we include logic to mount all existing subcommands from `anaconda-client` as top-level subcommands.
`anaconda-client` subcommands continue to work until overridden by new plugins, but may not be displayed in the global help output.
We also include all subcommands under the namespace `anaconda org`, e.g. `anaconda org upload`.
The help for all nested subcommands can be accessed with `anaconda org --help`.

Users may disable the new plugin system by setting the environment variable `ANACONDA_CLIENT_FORCE_STANDALONE=1`.

In addition to automated testing, this release has undergone an extensive internal QA process.
However, if any unintended regressions do occur, please file a bug in our issue tracker.

### Pull requests merged

* [PR 717](https://github.com/anaconda/anaconda-client/pull/717) - Drop dependency on `six`
* [PR 718](https://github.com/anaconda/anaconda-client/pull/718) - Fix local development setup via `make init`
* [PR 719](https://github.com/anaconda/anaconda-client/pull/719) - Migrate `anaconda-client` to become a plugin of `anaconda-cli-base`
* [PR 711](https://github.com/anaconda/anaconda-client/pull/711) - Remove duplicate import
* [PR 714](https://github.com/anaconda/anaconda-client/pull/714) - Updated links in upload help text
* [PR 724](https://github.com/anaconda/anaconda-client/pull/724) - Use conda package streaming to fix bug in upload of packages with bad permissions

## 1.12.3 - 2024-02-22

### Tickets closed
Expand Down
26 changes: 23 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,36 @@ Commands:
endef
export HELP

# Conda-related paths
conda_env_dir ?= ./env

# Command aliases
CONDA_EXE ?= conda
CONDA_RUN := $(CONDA_EXE) run --prefix $(conda_env_dir) --no-capture-output

.PHONY: help init lint lint-bandit lint-mypy lint-pycodestyle lint-pylint test test-pytest

help:
@echo "$${HELP}"

init:
@if [ -z "$${CONDA_SHLVL:+x}" ]; then echo "Conda is not installed." && exit 1; fi
@conda create -y -n anaconda_client python=3.12 --file requirements.txt --file requirements-extra.txt
@conda run -n anaconda_client pip install -r requirements-dev.txt
@echo "\n\nConda environment has been created. To activate run \"conda activate anaconda_client\"."
@conda create \
--channel defaults \
--channel anaconda-cloud \
--yes \
--prefix $(conda_env_dir) \
python=3.11 \
pip \
--file requirements.txt \
--file requirements-extra.txt
@conda run \
--prefix $(conda_env_dir) \
pip install -r requirements-dev.txt
@conda run \
--prefix $(conda_env_dir) \
pip install -e . --no-deps
@echo "\n\nConda environment has been created. To activate run \"conda activate $(conda_env_dir)\"."

check: lint test

Expand Down
1 change: 0 additions & 1 deletion autotest/data/test_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ dependencies:
- ripgrep=12.1.1=0
- ruamel_yaml=0.15.100=py38h27cfd23_0
- setuptools=52.0.0=py38h06a4308_0
- six=1.16.0=pyhd3eb1b0_0
- soupsieve=2.2.1=pyhd3eb1b0_0
- sqlite=3.35.4=hdfb4753_0
- tk=8.6.10=hbc83047_0
Expand Down
2 changes: 1 addition & 1 deletion binstar_client/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__all__ = ['__version__']

__version__ = '1.12.3'
__version__ = '1.13.0'
2 changes: 1 addition & 1 deletion binstar_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import logging
import os
import platform as _platform
from urllib.parse import quote

import defusedxml.ElementTree as ET
import requests
from pkg_resources import parse_version as pv
from six.moves.urllib.parse import quote
from tqdm import tqdm

from . import errors
Expand Down
1 change: 0 additions & 1 deletion binstar_client/commands/authorizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import pytz
from dateutil.parser import parse as parse_date
from six.moves import input

from binstar_client import errors
from binstar_client.utils import get_server_api
Expand Down
19 changes: 7 additions & 12 deletions binstar_client/commands/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

"""
Usage:
anaconda download notebook
anaconda download user/notebook
anaconda download <package_name>
anaconda download <channel_name>/<package_name>
"""

from __future__ import unicode_literals
Expand All @@ -14,14 +14,14 @@
from binstar_client import errors
from binstar_client.utils import get_server_api
from binstar_client.utils.config import PackageType
from binstar_client.utils.notebook import parse, has_environment
from binstar_client.utils.notebook import parse
from binstar_client.utils.notebook.downloader import Downloader

logger = logging.getLogger('binstar.download')


def add_parser(subparsers):
description = 'Download notebooks from your Anaconda repository'
description = 'Download packages from your Anaconda repository'
parser = subparsers.add_parser(
'download',
formatter_class=argparse.RawDescriptionHelpFormatter,
Expand All @@ -32,7 +32,7 @@ def add_parser(subparsers):

parser.add_argument(
'handle',
help='user/notebook',
help='<channel_name>/<package_name>',
action='store'
)

Expand All @@ -58,20 +58,15 @@ def add_parser(subparsers):

def main(args):
aserver_api = get_server_api(args.token, args.site)
username, notebook = parse(args.handle)
username, package_name = parse(args.handle)
username = username or aserver_api.user()['login']
downloader = Downloader(aserver_api, username, notebook)
downloader = Downloader(aserver_api, username, package_name)
packages_types = list(map(PackageType, args.package_type) if args.package_type else PackageType)

try:
download_files = downloader.list_download_files(packages_types, output=args.output, force=args.force)
for download_file, download_dist in download_files.items():
downloader.download(download_dist)
logger.info('%s has been downloaded as %s', args.handle, download_file)
if has_environment(download_file):
logger.info('%s has an environment embedded.', download_file)
logger.info('Run:')
logger.info(' conda env create %s', download_file)
logger.info('To install the environment in your system')
except (errors.DestinationPathExists, errors.NotFound, errors.BinstarError, OSError) as err:
logger.info(err)
4 changes: 1 addition & 3 deletions binstar_client/commands/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import platform
import socket
import sys

from six.moves import input
from six.moves.urllib.parse import urlparse
from urllib.parse import urlparse

from binstar_client import errors
from binstar_client.utils import get_config, get_server_api, store_token, bool_input
Expand Down
Loading

0 comments on commit 0899200

Please sign in to comment.