Skip to content

Commit 8362ad7

Browse files
authored
chore: deprecate this package (#407)
1 parent 27e833f commit 8362ad7

5 files changed

Lines changed: 144 additions & 72 deletions

File tree

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
----
2+
> **⚠️ DEPRECATION NOTICE**
3+
>
4+
> **gradient-cli v2 is deprecated.** v3 of this project will host the DigitalOcean Gradient SDK.
5+
> Development for the new version will be in https://github.com/digitalocean/gradient-python.
6+
>
7+
> **Users are advised to pin to v2 of this library** to avoid breaking changes.
8+
----
9+
110
----
211
> **Note**
312
> We are rolling out a new streamlined [Paperspace CLI](https://github.com/Paperspace/cli) and recommend using this new CLI for all new projects.
@@ -19,7 +28,7 @@ Gradient CLI
1928

2029
<br>
2130

22-
Gradient is an an end-to-end MLOps platform that enables individuals and organizations to quickly develop, train, and deploy Deep Learning models. The Gradient software stack runs on any infrastructure e.g. AWS, GCP, on-premise and low-cost [Paperspace GPUs](https://docs.paperspace.com/gradient/machines/). Leverage automatic versioning, distributed training, built-in graphs & metrics, hyperparameter search, GradientCI, 1-click Jupyter Notebooks, our Python SDK, and more.
31+
Gradient is an an end-to-end MLOps platform that enables individuals and organizations to quickly develop, train, and deploy Deep Learning models. The Gradient software stack runs on any infrastructure e.g. AWS, GCP, on-premise and low-cost [Paperspace GPUs](https://docs.paperspace.com/gradient/machines/). Leverage automatic versioning, distributed training, built-in graphs & metrics, hyperparameter search, GradientCI, 1-click Jupyter Notebooks, our Python SDK, and more.
2332

2433
Key components:
2534

@@ -38,16 +47,19 @@ See [releasenotes.md](https://github.com/Paperspace/gradient-cli/blob/master/rel
3847

3948
Getting Started
4049
===============
50+
51+
> **⚠️ IMPORTANT:** This library is deprecated. Pin to v2 to avoid breaking changes: `pip install "gradient<3.0"`
52+
4153
1. Make sure you have a Paperspace account set up. Go to [http://paperspace.com](https://console.paperspace.com/signup?gradient=true)
4254
to register and generate an API key.
4355

4456
2. Use pip, pipenv, or conda to install the gradient package, e.g.:
4557

46-
`pip install -U gradient`
58+
`pip install "gradient<3.0"` # Pin to v2 to avoid breaking changes
4759

48-
To install/update prerelease (Alpha/Beta) version version of gradient, use:
60+
To install/update prerelease (Alpha/Beta) version version of gradient v2, use:
4961

50-
`pip install -U --pre gradient`
62+
`pip install -U --pre "gradient<3.0"`
5163

5264
3. Set your api key by executing the following:
5365

@@ -70,7 +82,7 @@ gradient projects list
7082
gradient workflows create --name <name> --projectId <project-id>
7183
```
7284

73-
For a full list of available commands run `gradient workflows --help`. You can also view more info about Workflows in the [docs](https://docs.paperspace.com/gradient/explore-train-deploy/workflows).
85+
For a full list of available commands run `gradient workflows --help`. You can also view more info about Workflows in the [docs](https://docs.paperspace.com/gradient/explore-train-deploy/workflows).
7486

7587
Contributing
7688
============

gradient/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
# noinspection PyUnresolvedReferences
2+
import warnings
3+
4+
# Issue deprecation warning when the library is imported
5+
warnings.warn(
6+
"gradient-cli v2 is deprecated. v3 of this project will host the DigitalOcean Gradient SDK. "
7+
"Development for the new version will be in https://github.com/digitalocean/gradient-python. "
8+
"Users are advised to pin to v2 of this library.",
9+
DeprecationWarning,
10+
stacklevel=2,
11+
)
12+
213
from gradient_utils import *
314

415
from .api_sdk import *

gradient/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from gradient import version_checker
23
from gradient.cli.cli import cli as _cli_entry_point
34

gradient/version_checker.py

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
import os
22
import sys
33
from platform import system
4+
import json
45

5-
import six
6+
import requests
67
from distutils.version import StrictVersion
78

89
from gradient.clilogger import CliLogger
910
from gradient.version import version
1011

11-
if six.PY2:
12-
import xmlrpclib
13-
else:
14-
import xmlrpc.client as xmlrpclib
15-
1612
logger = CliLogger()
1713

1814

@@ -24,16 +20,59 @@ class VersionChecker(object):
2420
def is_up_to_date(self, module_name, current_version):
2521
version_in_repository = self.get_version_from_repository(module_name)
2622

27-
up_to_date = StrictVersion(current_version) >= StrictVersion(version_in_repository)
23+
up_to_date = StrictVersion(current_version) >= StrictVersion(
24+
version_in_repository
25+
)
2826
return up_to_date, version_in_repository
2927

30-
def get_version_from_repository(self, module_name, repository_url="http://pypi.python.org/pypi"):
31-
pypi = xmlrpclib.ServerProxy(repository_url)
32-
versions = pypi.package_releases(module_name)
33-
if not versions:
34-
raise PackageNotFoundError("Package {} not found".format(module_name))
28+
def get_version_from_repository(
29+
self, module_name, repository_url="https://pypi.org/pypi"
30+
):
31+
# Use PyPI JSON API instead of XML-RPC
32+
json_url = f"{repository_url}/{module_name}/json"
3533

36-
return versions[0]
34+
try:
35+
response = requests.get(json_url, timeout=5)
36+
response.raise_for_status()
37+
data = response.json()
38+
except (requests.RequestException, json.JSONDecodeError) as e:
39+
raise PackageNotFoundError(
40+
"Package {} not found or API error: {}".format(module_name, str(e))
41+
)
42+
43+
# Get all release versions
44+
releases = data.get("releases", {})
45+
if not releases:
46+
raise PackageNotFoundError(
47+
"No releases found for package {}".format(module_name)
48+
)
49+
50+
# Get all version numbers
51+
versions = list(releases.keys())
52+
if not versions:
53+
raise PackageNotFoundError(
54+
"No versions found for package {}".format(module_name)
55+
)
56+
57+
# Filter to only include versions < 3.0 (v2 versions only)
58+
v2_versions = []
59+
for v in versions:
60+
try:
61+
if StrictVersion(v) < StrictVersion("3.0.0"):
62+
v2_versions.append(v)
63+
except ValueError:
64+
# Skip invalid version strings
65+
continue
66+
67+
if not v2_versions:
68+
# If no v2 versions found, raise exception to skip the check
69+
raise PackageNotFoundError(
70+
"No v2 versions found for package {}".format(module_name)
71+
)
72+
73+
# Sort v2_versions to get the latest one (highest version number)
74+
v2_versions.sort(key=lambda x: StrictVersion(x), reverse=True)
75+
return v2_versions[0]
3776

3877

3978
class GradientVersionChecker(object):
@@ -74,9 +113,15 @@ def look_for_new_version():
74113
return
75114

76115
if not up_to_date:
77-
msg = "Warning: this version of the Gradient CLI ({current_version}) is out of date. " \
78-
"Some functionality might not be supported until you upgrade. \n\n" \
79-
"Run `pip install -U gradient` to upgrade\n".format(current_version=version)
116+
msg = (
117+
"Warning: this version of the Gradient CLI ({current_version}) is out of date. "
118+
"Some functionality might not be supported until you upgrade. \n\n"
119+
"The latest v2 version is {version_from_repository}.\n"
120+
'Run `pip install -U "gradient<3.0"` to upgrade to the latest v2 version\n'
121+
"Note: v3+ will be the DigitalOcean Gradient SDK. Pin to v2 to avoid breaking changes.\n".format(
122+
current_version=version
123+
)
124+
)
80125
logger.warning(msg)
81126

82127
@staticmethod

setup.py

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -16,80 +16,83 @@
1616
try:
1717
import pypandoc
1818

19-
long_description = pypandoc.convert('README.md', 'rst')
20-
except(IOError, ImportError, OSError):
21-
with open('README.md', encoding='utf-8') as f:
19+
long_description = pypandoc.convert("README.md", "rst")
20+
except (IOError, ImportError, OSError):
21+
with open("README.md", encoding="utf-8") as f:
2222
long_description = f.read()
2323

2424

2525
class VerifyVersionCommand(install):
2626
"""Custom command to verify that the git tag matches our version"""
27-
description = 'verify that the git tag matches our version'
27+
28+
description = "verify that the git tag matches our version"
2829

2930
def run(self):
30-
if '0.0.0' == version:
31+
if "0.0.0" == version:
3132
sys.exit("Version unspecified")
3233

3334

3435
setup(
35-
name='gradient',
36+
name="gradient",
3637
version=version,
37-
description='Paperspace Python',
38+
description="Paperspace Python",
3839
long_description=long_description,
3940
long_description_content_type="text/markdown",
40-
url='https://github.com/paperspace/gradient-cli',
41-
author='Paperspace Co.',
42-
author_email='info@paperspace.com',
41+
url="https://github.com/paperspace/gradient-cli",
42+
author="Paperspace Co.",
43+
author_email="info@paperspace.com",
4344
classifiers=[
44-
'Development Status :: 4 - Beta',
45-
'Intended Audience :: Developers',
46-
'Topic :: Software Development :: Libraries',
47-
'License :: OSI Approved :: ISC License (ISCL)',
48-
'Programming Language :: Python :: 2.7',
49-
'Programming Language :: Python :: 3.5',
50-
'Programming Language :: Python :: 3.6',
51-
'Programming Language :: Python :: 3.7',
52-
'Programming Language :: Python :: 3.8',
45+
"Development Status :: 7 - Inactive",
46+
"Intended Audience :: Developers",
47+
"Topic :: Software Development :: Libraries",
48+
"License :: OSI Approved :: ISC License (ISCL)",
49+
"Programming Language :: Python :: 2.7",
50+
"Programming Language :: Python :: 3.5",
51+
"Programming Language :: Python :: 3.6",
52+
"Programming Language :: Python :: 3.7",
53+
"Programming Language :: Python :: 3.8",
5354
],
54-
keywords='paperspace api development library',
55-
packages=find_packages(exclude=['contrib', 'docs', 'tests', 'old_tests']),
55+
keywords="paperspace api development library",
56+
packages=find_packages(exclude=["contrib", "docs", "tests", "old_tests"]),
5657
install_requires=[
57-
'requests[security]',
58-
'six',
59-
'click>=8.0.1,<9.0',
60-
'terminaltables',
61-
'click-didyoumean',
62-
'click-help-colors',
63-
'click-completion',
64-
'colorama==0.4.3',
65-
'requests-toolbelt',
66-
'progressbar2',
67-
'halo',
68-
'marshmallow<3.0',
69-
'attrs<=19',
70-
'PyYAML==5.3.1',
71-
'python-dateutil==2.*',
72-
'websocket-client==0.57.*',
73-
'gradient-utils>=0.1.2',
74-
'gql[requests]==3.0.0a6',
75-
'windows-curses>=2.3.0 ; platform_system=="Windows"'
58+
"requests[security]",
59+
"six",
60+
"click>=8.0.1,<9.0",
61+
"terminaltables",
62+
"click-didyoumean",
63+
"click-help-colors",
64+
"click-completion",
65+
"colorama==0.4.3",
66+
"requests-toolbelt",
67+
"progressbar2",
68+
"halo",
69+
"marshmallow<3.0",
70+
"attrs<=19",
71+
"PyYAML==5.3.1",
72+
"python-dateutil==2.*",
73+
"websocket-client==0.57.*",
74+
"gradient-utils>=0.1.2",
75+
"gql[requests]==3.0.0a6",
76+
'windows-curses>=2.3.0 ; platform_system=="Windows"',
7677
],
77-
entry_points={'console_scripts': [
78-
'gradient = gradient:main.main',
79-
]},
78+
entry_points={
79+
"console_scripts": [
80+
"gradient = gradient:main.main",
81+
]
82+
},
8083
extras_require={
8184
"dev": [
82-
'tox',
83-
'pytest',
84-
'mock',
85-
'twine',
86-
'sphinx',
85+
"tox",
86+
"pytest",
87+
"mock",
88+
"twine",
89+
"sphinx",
8790
'pathlib2;python_version<"3.4"',
88-
'sphinx-click',
89-
'recommonmark'
91+
"sphinx-click",
92+
"recommonmark",
9093
],
9194
},
9295
cmdclass={
93-
'verify': VerifyVersionCommand,
96+
"verify": VerifyVersionCommand,
9497
},
9598
)

0 commit comments

Comments
 (0)