Ejemplo n.º 1
0
def main(ctx, project, domain, config=None, pkgs=None, version=None, insecure=None):
    """
    Entrypoint for all the user commands.
    """
    update_configuration_file(config)

    # Update the logger if it's set
    log_level = _internal_config.LOGGING_LEVEL.get() or _sdk_config.LOGGING_LEVEL.get()
    if log_level is not None:
        _logging.getLogger().setLevel(log_level)

    ctx.obj = dict()
    ctx.obj[CTX_PROJECT] = project
    ctx.obj[CTX_DOMAIN] = domain
    version = version or _look_up_version_from_image_tag(_IMAGE.get())
    ctx.obj[CTX_VERSION] = version

    # Determine SSL.  Note that the insecure option in this command is not a flag because we want to look
    # up configuration settings if it's missing.  If the command line option says insecure but the config object
    # says no, let's override the config object by overriding the environment variable.
    if insecure and not _platform_config.INSECURE.get():
        _platform_config.INSECURE.get()
        _os.environ[_platform_config.INSECURE.env_var] = 'True'

    # Handle package management - get from config if not specified on the command line
    pkgs = pkgs or []
    if len(pkgs) == 0:
        pkgs = _WORKFLOW_PACKAGES.get()
    ctx.obj[CTX_PACKAGES] = pkgs

    _os.environ[_internal_config.PROJECT.env_var] = project
    _os.environ[_internal_config.DOMAIN.env_var] = domain
    _os.environ[_internal_config.VERSION.env_var] = version
Ejemplo n.º 2
0
def activate_all(ctx, version=None, ignore_schedules=False):
    """
    This command will activate all found launch plans at the given version.  If there are existing
    active launch plans that collide on project, domain, and name, but differ on version, those will be
    deactivated in favor of the version specified in this command. If a launch plan is associated with a schedule,
    the schedule will also be deactivated or activated as appropriate.

    Note:
        1.  Currently, this is not a transaction.  Therefore, if the command fails, it is possible that some schedules
            have been updated.
        2.  If a launch plan is scheduled on an older version for a given project, domain, and name AND there is not a
            matching scheduled launch plan found when running this command, the existing schedule will remain active
            until it is manually disabled.
    """
    project = ctx.obj[_constants.CTX_PROJECT]
    domain = ctx.obj[_constants.CTX_DOMAIN]
    pkgs = ctx.obj[_constants.CTX_PACKAGES]
    version = version or ctx.obj[
        _constants.CTX_VERSION] or _look_up_version_from_image_tag(
            _IMAGE.get())
    activate_all_impl(project,
                      domain,
                      version,
                      pkgs,
                      ignore_schedules=ignore_schedules)
Ejemplo n.º 3
0
def register(ctx, project, domain, version, pkgs=None, test=None):
    """
    Run registration steps for the workflows in this container.

    Run with the --test switch for a dry run to see what will be registered.  A default launch plan will also be
    created, if a role can be found in the environment variables.
    """
    if pkgs:
        raise click.UsageError(
            "--pkgs must now be specified before the 'register' keyword on the command line"
        )

    version = version or _look_up_version_from_image_tag(_IMAGE.get())
    if not version:
        raise click.UsageError(
            "Could not find image from config, please specify a value for ``--version``"
        )

    ctx.obj[CTX_PROJECT] = project
    ctx.obj[CTX_DOMAIN] = domain
    ctx.obj[CTX_VERSION] = version
    ctx.obj[CTX_TEST] = test
    _os.environ[_PROJECT.env_var] = project
    _os.environ[_DOMAIN.env_var] = domain
    _os.environ[_VERSION.env_var] = ctx.obj[CTX_VERSION]
Ejemplo n.º 4
0
def serialize(ctx):
    """
    This command produces protobufs for tasks and templates.
    For tasks, one pb file is produced for each task, representing one TaskTemplate object.
    For workflows, one pb file is produced for each workflow, representing a WorkflowClosure object.  The closure
        object contains the WorkflowTemplate, along with the relevant tasks for that workflow.  In lieu of Admin,
        this serialization step will set the URN of the tasks to the fully qualified name of the task function.
    """
    click.echo('Serializing Flyte elements with image {}'.format(_IMAGE.get()))
Ejemplo n.º 5
0
def tasks(ctx, version=None):
    """
    Only register tasks.
    """
    project = ctx.obj[CTX_PROJECT]
    domain = ctx.obj[CTX_DOMAIN]
    test = ctx.obj[CTX_TEST]
    pkgs = ctx.obj[CTX_PACKAGES]

    version = version or ctx.obj[CTX_VERSION] or _look_up_version_from_image_tag(_IMAGE.get())
    register_tasks_only(project, domain, pkgs, test, version)
Ejemplo n.º 6
0
def workflows(ctx, version=None):
    """
    Register both tasks and workflows.  Also create and register a default launch plan for all workflows.
    """
    project = ctx.obj[CTX_PROJECT]
    domain = ctx.obj[CTX_DOMAIN]
    test = ctx.obj[CTX_TEST]
    pkgs = ctx.obj[CTX_PACKAGES]

    version = version or ctx.obj[CTX_VERSION] or _look_up_version_from_image_tag(_IMAGE.get())
    register_all(project, domain, pkgs, test, version)
Ejemplo n.º 7
0
def activate_all_schedules(ctx, version=None):
    """
    THIS COMMAND IS DEPRECATED. PLEASE USE activate-all

    The behavior of this command is identical to activate-all.
    """
    click.secho(
        "activate-all-schedules is deprecated, please use activate-all instead.",
        color="yellow")
    project = ctx.obj[_constants.CTX_PROJECT]
    domain = ctx.obj[_constants.CTX_DOMAIN]
    pkgs = ctx.obj[_constants.CTX_PACKAGES]
    version = version or ctx.obj[
        _constants.CTX_VERSION] or _look_up_version_from_image_tag(
            _IMAGE.get())
    activate_all_impl(project, domain, version, pkgs)
Ejemplo n.º 8
0
def launch_plans(ctx, project, domain, version):
    """
    Launch plan control group, including executions
    """

    version = version or _look_up_version_from_image_tag(_IMAGE.get())
    if not version:
        raise click.UsageError(
            "Could not find image from config, please specify a value for ``--version``"
        )

    ctx.obj[CTX_PROJECT] = project
    ctx.obj[CTX_DOMAIN] = domain
    ctx.obj[CTX_VERSION] = version
    _os.environ[_PROJECT.env_var] = project
    _os.environ[_DOMAIN.env_var] = domain
    _os.environ[_VERSION.env_var] = version