Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit 9bac966

Browse files
committed
deprecated decorator
1 parent fdee391 commit 9bac966

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

paperspace/cli/common.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import functools
12
import getpass
23

34
import click
4-
from click import group
55
from click_didyoumean import DYMMixin
66
from click_help_colors import HelpColorsGroup
77

@@ -32,10 +32,10 @@ def group(self, *args, **kwargs):
3232
aliases.append(kwargs.pop('alias'))
3333

3434
def decorator(f):
35-
cmd = group(*_args, **kwargs)(f)
35+
cmd = click.group(*_args, **kwargs)(f)
3636
self.add_command(cmd)
3737
for alias in set(aliases):
38-
alias_cmd = group(alias, **kwargs)(f)
38+
alias_cmd = click.group(alias, **kwargs)(f)
3939
self.add_command(alias_cmd)
4040
alias_cmd.commands = cmd.commands
4141
return cmd
@@ -51,3 +51,20 @@ def callback_fun(ctx, param, value):
5151
return value
5252

5353
return callback_fun
54+
55+
56+
def deprecated(f, version="1.0.0"):
57+
deprecated_invoke_notice = """DeprecatedWarning: \nWARNING: This command will not be included in version %s .
58+
For more information, please see:
59+
60+
https://docs.paperspace.com
61+
If you depend on functionality not listed there, please file an issue.""" % version
62+
63+
def new_invoke(self, ctx):
64+
click.echo(click.style(deprecated_invoke_notice, fg='red'), err=True)
65+
super(type(self), self).invoke(ctx)
66+
67+
def decorator():
68+
f.invoke = functools.partial(new_invoke, f)
69+
70+
return decorator()

paperspace/cli/run.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
from paperspace import client, config
44
from paperspace.cli import common
55
from paperspace.cli.cli import cli
6-
from paperspace.cli.common import del_if_value_is_none
6+
from paperspace.cli.common import del_if_value_is_none, deprecated
77
from paperspace.cli.jobs import common_jobs_create_options
88
from paperspace.commands.run import RunCommand
99
from paperspace.constants import RunMode
1010

1111

12-
@cli.command("new-run")
12+
@deprecated
13+
@cli.command("run", help="Run script or command on remote cluster")
1314
@click.option("-c", "--python-command", "mode", flag_value=RunMode.RUN_MODE_PYTHON_COMMAND)
1415
@click.option("-m", "--module", "mode", flag_value=RunMode.RUN_MODE_PYTHON_MODULE)
1516
@click.option("-s", "--shell", "mode", flag_value=RunMode.RUN_MODE_SHELL_COMMAND)

tests/functional/test_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class TestRunCommand(object):
12-
command_name = 'new-run'
12+
command_name = 'run'
1313
common_commands = ["--name", "test", "--projectId", "projectId", "--apiKey", "some_key"]
1414
url = "https://api.paperspace.io/jobs/createJob/"
1515
headers = default_headers.copy()

0 commit comments

Comments
 (0)