Skip to content

Commit

Permalink
Merge pull request #673 from Anaconda-Platform/release/1.12.0
Browse files Browse the repository at this point in the history
Release 1.12.0
  • Loading branch information
vshevchenko-anaconda authored Jul 18, 2023
2 parents 3dc50e5 + 5bc3d81 commit bb2e957
Show file tree
Hide file tree
Showing 34 changed files with 1,705 additions and 1,036 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

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

## 1.12.0 - 2023-07-18

### Tickets closed

* AC-155 - Package upload improvements
* AC-163 - Do not use 'none' as a package type
* AC-164 - Allow main entrypoint plugin
* AC-165 - Remove dependency on deprecated urllib3 function
* AC-167 - Address reported anaconda-client issues

### Pull requests merged

* [PR 672](https://github.com/Anaconda-Platform/anaconda-client/pull/672) - AC-164: anaconda cli entrypoints support
* [PR 670](https://github.com/Anaconda-Platform/anaconda-client/pull/670) - AC-167: fixes for some issues
* [PR 669](https://github.com/Anaconda-Platform/anaconda-client/pull/669) - AC-165: compatibility with urllib3
* [PR 664](https://github.com/Anaconda-Platform/anaconda-client/pull/664) - feat: Allow main entrypoint plugin
* [PR 663](https://github.com/Anaconda-Platform/anaconda-client/pull/663) - AC-163: fix default package types
* [PR 659](https://github.com/Anaconda-Platform/anaconda-client/pull/659) - AC-155: package upload improvements

## 1.11.3 - 2023-06-01

### Tickets closed
Expand Down
12 changes: 6 additions & 6 deletions autotest/autotest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ echo -e "/?\\\\ Download package:\\n"
rm -rf pkg_tmp
mkdir -p pkg_tmp/noarch pkg_tmp/linux-64
${TST_CMD} download "${TST_LOGIN}/conda_gc_test" -o pkg_tmp || (echo -e "\\n\\n/!\\\\ Download package test failed.\\n" && exit 1)
[ "$(find pkg_tmp -name conda_gc_test-1.2.1-3.tar.bz2 | wc -l)" = 1 ] || (echo -e "\\n\\n/!\\\\ Download package test failed.\\n" && exit 1)
[ $(find pkg_tmp -name conda_gc_test-1.2.1-3.tar.bz2 | wc -l) = 1 ] || (echo -e "\\n\\n/!\\\\ Download package test failed.\\n" && exit 1)
rm -rf pkg_tmp
echo

rm -rf pkg_tmp
mkdir -p pkg_tmp/noarch pkg_tmp/linux-64
${TST_CMD} download "${TST_LOGIN}/bcj-cffi" -o pkg_tmp || (echo -e "\\n\\n/!\\\\ Download package test failed.\\n" && exit 1)
[ "$(find pkg_tmp -name bcj-cffi-0.5.1-py310h295c915_0.tar.bz2 | wc -l)" = 1 ] || (echo -e "\\n\\n/!\\\\ Download package test failed.\\n" && exit 1)
[ $(find pkg_tmp -name bcj-cffi-0.5.1-py310h295c915_0.tar.bz2 | wc -l) = 1 ] || (echo -e "\\n\\n/!\\\\ Download package test failed.\\n" && exit 1)
rm -rf pkg_tmp
echo

Expand All @@ -69,7 +69,7 @@ echo -e "/?\\\\ Download notebook:\\n"
rm -rf nbk_tmp
mkdir -p nbk_tmp
${TST_CMD} download "${TST_LOGIN}/hello_binstar" -o nbk_tmp || (echo -e "\\n\\n/!\\\\ Download notebook test failed.\\n" && exit 1)
[ "$(find nbk_tmp -name hello_binstar.ipynb | wc -l)" = 1 ] || (echo -e "\\n\\n/!\\\\ Download notebook test failed.\\n" && exit 1)
[ $(find nbk_tmp -name hello_binstar.ipynb | wc -l) = 1 ] || (echo -e "\\n\\n/!\\\\ Download notebook test failed.\\n" && exit 1)
rm -rf nbk_tmp
echo

Expand All @@ -85,7 +85,7 @@ echo -e "/?\\\\ Download environment:\\n"
rm -rf env_tmp
mkdir -p env_tmp
${TST_CMD} download "${TST_LOGIN}/test_env" -o env_tmp || (echo -e "\\n\\n/!\\\\ Download environment test failed.\\n" && exit 1)
[ "$(find env_tmp -name test_env.yml | wc -l)" = 1 ] || (echo -e "\\n\\n/!\\\\ Download environment test failed.\\n" && exit 1)
[ $(find env_tmp -name test_env.yml | wc -l) = 1 ] || (echo -e "\\n\\n/!\\\\ Download environment test failed.\\n" && exit 1)
rm -rf env_tmp
echo

Expand All @@ -111,14 +111,14 @@ echo -e "/?\\\\ Download copied package:\\n"
rm -rf pkg_tmp
mkdir -p pkg_tmp/linux-32 pkg_tmp/linux-64 pkg_tmp/linux-aarch64 pkg_tmp/linux-ppc64le pkg_tmp/linux-s390x pkg_tmp/noarch pkg_tmp/osx-64 pkg_tmp/osx-arm64 pkg_tmp/win-32 pkg_tmp/win-64
${TST_CMD} download "${TST_LOGIN}/pip" -o pkg_tmp || (echo -e "\\n\\n/!\\\\ Download copied package test failed.\\n" && exit 1)
[ "$(find pkg_tmp -name 'pip-21.2.4-*.tar.bz2' | wc -l)" ">" 0 ] || (echo -e "\\n\\n/!\\\\ Download copied package test failed.\\n" && exit 1)
[ $(find pkg_tmp -name 'pip-21.2.4-*.tar.bz2' | wc -l) ">" 0 ] || (echo -e "\\n\\n/!\\\\ Download copied package test failed.\\n" && exit 1)
rm -rf pkg_tmp
echo

rm -rf pkg_tmp
mkdir -p pkg_tmp/linux-32 pkg_tmp/linux-64 pkg_tmp/linux-aarch64 pkg_tmp/linux-ppc64le pkg_tmp/linux-s390x pkg_tmp/noarch pkg_tmp/osx-64 pkg_tmp/osx-arm64 pkg_tmp/win-32 pkg_tmp/win-64
${TST_CMD} download "${TST_LOGIN}/git-lfs" -o pkg_tmp || (echo -e "\\n\\n/!\\\\ Download copied package test failed.\\n" && exit 1)
[ "$(find pkg_tmp -name 'git-lfs-2.13.3-*.tar.bz2' | wc -l)" ">" 0 ] || (echo -e "\\n\\n/!\\\\ Download copied package test failed.\\n" && exit 1)
[ $(find pkg_tmp -name 'git-lfs-2.13.3-*.tar.bz2' | wc -l) ">" 0 ] || (echo -e "\\n\\n/!\\\\ Download copied package test failed.\\n" && exit 1)
rm -rf pkg_tmp
echo

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.11.3'
__version__ = '1.12.0'
12 changes: 4 additions & 8 deletions binstar_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,8 @@ def session(self):
return self._session

def check_server(self):
"""
Checks if the server is reachable and throws
and exception if it isn't
"""
msg = 'API server not found. Please check your API url configuration.'
"""Check if server is reachable or throw an exception if it isn't."""
msg = 'API server is unavailable. Please check your API url configuration.'

try:
response = self.session.head(self.domain)
Expand Down Expand Up @@ -352,14 +349,13 @@ def add_package( # pylint: disable=too-many-arguments
:param public: if true then the package will be hosted publicly
:param attrs: A dictionary of extra attributes for this package
"""
if package_type is not None:
package_type = package_type.value
package_types = [] if package_type is None else [package_type.value]

url = '%s/package/%s/%s' % (self.domain, login, package_name)

attrs = attrs or {}
attrs['summary'] = summary
attrs['package_types'] = [package_type]
attrs['package_types'] = package_types
attrs['license'] = {
'name': license,
'url': license_url,
Expand Down
64 changes: 37 additions & 27 deletions binstar_client/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,68 @@

"""Update public attributes of the package or the attributes of the package release."""

import typing
from __future__ import annotations

__all__ = ['add_parser']

import argparse
import json
import logging
import os
import typing

import yaml

from binstar_client import errors
from binstar_client.utils import get_server_api
from binstar_client.utils import parse_specs
from binstar_client.utils.detect import detect_package_type, get_attrs
from binstar_client.utils import detect

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


def get_attributes(
package: str,
package_type: typing.Any,
args: argparse.Namespace,
) -> typing.Tuple[typing.Mapping[str, typing.Any], typing.Mapping[str, typing.Any]]:
Attributes = typing.Mapping[str, typing.Any]


def get_attributes(package: str, args: argparse.Namespace) -> typing.Tuple[Attributes, Attributes]:
"""Parse source for attribute details."""
loader: typing.Optional[typing.Callable[[typing.TextIO], typing.Mapping[str, typing.Any]]] = None
loader: typing.Optional[typing.Callable[[typing.TextIO], detect.PackageAttributes]] = None
if package.endswith('.json'):
loader = json.load
elif package.endswith(('.yml', '.yaml')):
loader = yaml.safe_load

package_attrs: typing.Mapping[str, typing.Any]
release_attrs: typing.Mapping[str, typing.Any]
if loader is None:
package_attrs, release_attrs, _ = get_attrs(package_type, package, parser_args=args)
else:
if loader is not None:
stream: typing.TextIO
with open(package, 'rt', encoding='utf-8') as stream:
package_attrs = release_attrs = loader(stream)
return (loader(stream),) * 2

package_type: typing.Optional[detect.PackageType]
if args.package_type:
package_type = detect.PackageType(args.package_type)
else:
package_type = detect.detect_package_type(package)
if package_type is None:
message: str = (
f'Could not detect package type of file "{package}". '
'Please specify package type with option --package-type'
)
logger.error(message)
raise errors.BinstarError(message)

return package_attrs, release_attrs
try:
return detect.get_attrs(package_type, package, parser_args=args)[:2]
except Exception as error:
message = f'Trouble reading metadata from {package}. Is this a valid source file: {package_type.label}?'
logger.error(message)
raise errors.BinstarError(message) from error


def main(args: argparse.Namespace) -> None:
"""Process update request."""
anaconda_api = get_server_api(args.token, args.site)
anaconda_api.check_server()

package_type = detect_package_type(args.source)
try:
package_attrs, release_attrs = get_attributes(args.source, package_type, args)
except Exception as error:
message = 'Trouble reading metadata from {}. Is this a valid source file: {} ?'.format(
args.source, package_type.label())
logger.error(message)
raise errors.BinstarError(message) from error

attrs = package_attrs if not args.release else release_attrs
attrs: Attributes = get_attributes(args.source, args)[bool(args.release)]
attrs = attrs.get('public_attrs', attrs)

if args.release:
Expand Down Expand Up @@ -89,7 +95,7 @@ def add_parser(subparsers: typing.Any) -> None:
parser = subparsers.add_parser(
'update',
usage=(
'\n\tanaconda update [--release] user/package[/version] CONDA_PACKAGE_1.bz2'
'\n\tanaconda update [--release] user/package[/version] CONDA_PACKAGE_1.tar.bz2'
'\n\tanaconda update [--release] user/package[/version] metadata.json'
),
description=__doc__,
Expand All @@ -108,6 +114,10 @@ def add_parser(subparsers: typing.Any) -> None:
),
type=file_type,
)
parser.add_argument(
'-t', '--package-type',
help='Set the package type. Defaults to autodetect',
)

release_group = parser.add_argument_group(title='Update release')
release_group.add_argument(
Expand Down
Loading

0 comments on commit bb2e957

Please sign in to comment.