Skip to content

Update/sky 0.7 #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ dmypy.json
# Cython debug symbols
cython_debug/
*pymc.yaml

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ nutpie
lifetimes
numba
ray[default]
skypilot
skypilot[gcp]
skypilot==0.7.0
skypilot[gcp]==0.7.0
hiyapyco
84 changes: 46 additions & 38 deletions src/pymc_server/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
from typing import Any, Dict, List, Optional, Tuple, Union
from pymc_server.utils.yaml import merge_yaml
#from pymc_server.commands.launch_cli import launch as cli_launch,cli_launch_
from pymc_server.commands.launch_cli import launch_2
from pymc_server.commands.down_cli import down as down_cli
from pymc_server.cli_factory import setup_launch_factory, setup_status_factory
from pymc_server.commands.down_cli import (down as down_cli, setup_down_factory as setup_down_factory)
from pymc_server.commands.launch_cli import launch as launch_cli
from pymc_server.commands.exec_cli import exec as exec_cli
from pymc_server.commands.status_cli import status as status_cli
from pymc_server.commands.start_cli import start as start_cli

from pymc_server.cli_factory import setup_launch_factory, setup_status_factory, setup_exec_factory, setup_start_factory,setup_stop_factory
from sky.usage import usage_lib
from sky.cli import _get_shell_complete_args, _get_click_major_version, _complete_cluster_name, _NaturalOrderGroup, _DocumentedCodeCommand



from sky.cli import (
status as sky_status,
launch as sky_launch,
check as sky_check
check as sky_check,
start as sky_start,
stop as sky_stop
)

# TODO: remove, check pyproject.py for a reference to this function
Expand All @@ -28,12 +32,23 @@ def status(*args, **kwargs):
""" calls the sky status command by passing the click context"""
ctx = click.get_current_context()
#ctx.invoke(_status_test, *args, **kwargs)
data = ctx.invoke(sky_status, *args, **kwargs)
#print("*args",*args)
data = ctx.invoke(status_cli, *args, **kwargs)
#print("DATA",data)

#ctx.invoke(sky_status, *args, **kwargs)


@setup_exec_factory
@usage_lib.entrypoint
def exec(*args, **kwargs):
""" calls the sky status command by passing the click context"""
ctx = click.get_current_context()
#sky_check(*args, **kwargs)
ctx.invoke(exec_cli, *args, **kwargs)
#sads


@setup_launch_factory
@usage_lib.entrypoint
def launch(*args, **kwargs):
Expand All @@ -47,8 +62,7 @@ def launch(*args, **kwargs):
"""
# cli_launch(*args, **kwargs)
ctx = click.get_current_context()
ctx.invoke(launch_2, *args, **kwargs)
#ctx.invoke(sky_launch, *args, **kwargs)
ctx.invoke(launch_cli, *args, **kwargs)

@setup_status_factory
@usage_lib.entrypoint
Expand All @@ -59,34 +73,25 @@ def check(*args, **kwargs):
ctx.invoke(sky_check, *args, **kwargs)


@cli.command(cls=_DocumentedCodeCommand)
@click.argument('clusters',
nargs=-1,
required=False,
**_get_shell_complete_args(_complete_cluster_name))
@click.option('--all',
'-a',
default=None,
is_flag=True,
help='Tear down all existing clusters.')
@click.option('--yes',
'-y',
is_flag=True,
default=False,
required=False,
help='Skip confirmation prompt.')
@click.option(
'--purge',
'-p',
is_flag=True,
default=False,
required=False,
help=('(Advanced) Forcefully remove the cluster(s) from '
'SkyPilot\'s cluster table, even if the actual cluster termination '
'failed on the cloud. WARNING: This flag should only be set sparingly'
' in certain manual troubleshooting scenarios; with it set, it is the'
' user\'s responsibility to ensure there are no leaked instances and '
'related resources.'))


@setup_start_factory
@usage_lib.entrypoint
def start(*args, **kwargs):
ctx = click.get_current_context()
#sky_check(*args, **kwargs)
ctx.invoke(start_cli, *args, **kwargs)
"""Deletes a local cluster."""

@setup_stop_factory
@usage_lib.entrypoint
def stop(*args, **kwargs):
ctx = click.get_current_context()
#sky_check(*args, **kwargs)
ctx.invoke(sky_stop, *args, **kwargs)
"""Deletes a local cluster."""

@setup_down_factory
@usage_lib.entrypoint
def down(*args, **kwargs):
ctx = click.get_current_context()
Expand All @@ -95,10 +100,13 @@ def down(*args, **kwargs):
"""Deletes a local cluster."""



cli.add_command(status)
cli.add_command(launch)
cli.add_command(check)
cli.add_command(start)
cli.add_command(stop)
cli.add_command(down)
cli.add_command(exec)

if __name__ == '__main__':
cli()
Expand Down
151 changes: 150 additions & 1 deletion src/pymc_server/cli_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def setup_launch_factory(func):
'the same data on the boot disk as an existing cluster.')),
click.option(
'--down',
default=False,
default=None,
is_flag=True,
required=False,
help=
Expand All @@ -188,3 +188,152 @@ def setup_launch_factory(func):
for option in reversed(options):
func = option(func)
return func

def setup_exec_factory(func):
options = [
#cli.command(cls=_DocumentedCodeCommand),
click.command(cls=_DocumentedCodeCommand),

click.argument('cluster',
required=False,
type=str,
**_get_shell_complete_args(_complete_cluster_name)),
click.option(
'--cluster',
'-c',
'cluster_option',
hidden=True,
type=str,
help='This is the same as the positional argument, just for consistency.',
**_get_shell_complete_args(_complete_cluster_name)),
click.argument('entrypoint',
required=False,
type=str,
nargs=-1,
**_get_shell_complete_args(_complete_file_name)),
click.option('--module-name',
'-m',
#default='pymc-marketing',
required=False,
type=str,
help=('Define the PyMC module / project you need tu use. '
'pymc-marketing is default.')),
click.option('--base-config-folder',
'-b',
required=False,
type=str,
help=('define config base Folder')),
click.option(
'--detach-run',
'-d',
default=False,
is_flag=True,
help=('If True, as soon as a job is submitted, return from this call '
'and do not stream execution logs.')),
_add_click_options(_TASK_OPTIONS_WITH_NAME + _EXTRA_RESOURCES_OPTIONS),
usage_lib.entrypoint
]
for option in reversed(options):
func = option(func)
return func

def setup_start_factory(func):
options = [
click.command(cls=_DocumentedCodeCommand),
click.argument('clusters',
nargs=-1,
required=False,
**_get_shell_complete_args(_complete_cluster_name)),
click.option('--entrypoint',
'-e',
default=None,
type=str,
required=False,
**_get_shell_complete_args(_complete_file_name)),
click.option('--all',
'-a',
default=False,
is_flag=True,
required=False,
help='Start all existing clusters.'),
click.option('--yes',
'-y',
is_flag=True,
default=False,
required=False,
help='Skip confirmation prompt.'),
click.option(
'--idle-minutes-to-autostop',
'-i',
default=None,
type=int,
required=False,
help=('Automatically stop the cluster after this many minutes '
'of idleness, i.e., no running or pending jobs in the cluster\'s job '
'queue. Idleness gets reset whenever setting-up/running/pending jobs '
'are found in the job queue. '
'Setting this flag is equivalent to '
'running ``sky launch -d ...`` and then ``sky autostop -i <minutes>``'
'. If not set, the cluster will not be autostopped.')),
click.option(
'--down',
default=None,
is_flag=True,
required=False,
help=
('Autodown the cluster: tear down the cluster after specified minutes of '
'idle time after all jobs finish (successfully or abnormally). Requires '
'--idle-minutes-to-autostop to be set.'),
),
click.option(
'--retry-until-up',
'-r',
default=False,
is_flag=True,
required=False,
# Disabling quote check here, as there seems to be a bug in pylint,
# which incorrectly recognizes the help string as a docstring.
# pylint: disable=bad-docstring-quotes
help=('Retry provisioning infinitely until the cluster is up, '
'if we fail to start the cluster due to unavailability errors.'),
),
click.option(
'--force',
'-f',
default=False,
is_flag=True,
required=False,
help=('Force start the cluster even if it is already UP. Useful for '
'upgrading the SkyPilot runtime on the cluster.')),

usage_lib.entrypoint
]
for option in reversed(options):
func = option(func)
return func


def setup_stop_factory(func):
options = [

click.command(cls=_DocumentedCodeCommand),
click.argument('clusters',
nargs=-1,
required=False,
**_get_shell_complete_args(_complete_cluster_name)),
click.option('--all',
'-a',
default=None,
is_flag=True,
help='Stop all existing clusters.'),
click.option('--yes',
'-y',
is_flag=True,
default=False,
required=False,
help='Skip confirmation prompt.')

]
for option in reversed(options):
func = option(func)
return func
44 changes: 43 additions & 1 deletion src/pymc_server/commands/down_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,51 @@
from sky.usage import usage_lib
from sky.utils import controller_utils,subprocess_utils
from rich import progress as rich_progress
from sky.cli import _get_glob_clusters

import click
from sky.cli import (
_DocumentedCodeCommand,
_get_shell_complete_args,
_complete_cluster_name,
)

def setup_down_factory(func):
options = [
click.command(cls=_DocumentedCodeCommand),
click.argument('clusters',
nargs=-1,
required=False,
**_get_shell_complete_args(_complete_cluster_name)),
click.option('--all',
'-a',
default=None,
is_flag=True,
help='Tear down all existing clusters.'),
click.option('--yes',
'-y',
is_flag=True,
default=False,
required=False,
help='Skip confirmation prompt.'),
click.option(
'--purge',
'-p',
is_flag=True,
default=False,
required=False,
help=('(Advanced) Forcefully remove the cluster(s) from '
'SkyPilot\'s cluster table, even if the actual cluster termination '
'failed on the cloud. WARNING: This flag should only be set sparingly'
' in certain manual troubleshooting scenarios; with it set, it is the'
' user\'s responsibility to ensure there are no leaked instances and '
'related resources.')),
]
for option in reversed(options):
func = option(func)
return func


from sky.cli import _get_glob_clusters

prefix = "pymcs"
def local_down():
Expand Down
Loading