Beispiel #1
0
def restart(
    # Support the old way of passing mode so that an old version of
    # Orchest does not break when updating.
    mode: str = typer.Option(
        "reg",
        help=("Mode in which to start Orchest afterwards. This option is "
              "deprecated and will be removed in a future version. Use --dev "
              "instead of --mode=dev."),
        hidden=True,
    ),
    port: Optional[int] = typer.Option(
        8000, help="The port the Orchest webserver will listen on."),
    cloud: bool = typer.Option(
        False,
        show_default="--no-cloud",
        help=cli_start.__CLOUD_HELP_MESSAGE,
        hidden=True,
    ),
    dev: bool = typer.Option(False,
                             show_default="--no-dev",
                             help=cli_start.__DEV_HELP_MESSAGE),
):
    """
    Restart Orchest.
    """

    dev = dev or (mode == "dev")
    container_config = get_container_config(port, cloud=cloud, dev=dev)
    app.restart(container_config)
Beispiel #2
0
def reg(port: Optional[int] = typer.Option(
    8000, help="The port the Orchest webserver will listen on.")):
    """
    Start Orchest regularly.

    This is the default mode in which Orchest is started. Alias:

    \b
        orchest start [OPTIONS]
    """
    container_config = get_container_config("reg")

    port_bind: dict = {
        "nginx-proxy": {
            "HostConfig": {
                "PortBindings": {
                    "80/tcp": [{
                        "HostPort": f"{port}"
                    }],
                },
            },
        },
    }
    inject_dict(container_config, port_bind, overwrite=True)
    app.start(container_config)
Beispiel #3
0
def reg(
    port: Optional[int] = typer.Option(
        8000, help="The port the Orchest webserver will listen on."
    ),
    log_level: Optional[LogLevel] = typer.Option(
        None,
        "-l",
        "--log-level",
        show_default=False,
        help="Log level inside the application.",
    ),
    cloud: bool = typer.Option(
        False, show_default="--no-cloud", help=__CLOUD_HELP_MESSAGE, hidden=True
    ),
    dev: bool = typer.Option(False, show_default="--no-dev", help=__DEV_HELP_MESSAGE),
):
    """
    Start Orchest.

    Alias:

    \b
        orchest start [OPTIONS]
    """
    container_config = get_container_config(port, cloud, dev, log_level)

    if dev:
        logger.info(
            "Starting Orchest with --dev. This mounts host directories "
            "to monitor for source code changes."
        )

    app.start(container_config)
Beispiel #4
0
    def update(self, mode=None):
        """Update Orchest.

        Args:
            mode: The mode in which to update Orchest. This is either
                ``None`` or ``"web"``, where the latter is used when
                update is invoked through the update-server.

        """
        # Get all installed containers.
        pulled_images = self.resource_manager.get_images()

        # Pull images. It is possible to pull new image whilst the older
        # versions of those images are running.
        # TODO: remove the warning from the orchest.sh script that
        #       containers will be shut down.
        utils.echo("Updating...")

        _, running_containers = self.resource_manager.get_containers(state="running")
        if self.is_running(running_containers):
            utils.echo("Using Orchest whilst updating is NOT recommended.")

        # Update the Orchest git repo to get the latest changes to the
        # "userdir/" structure.
        exit_code = utils.update_git_repo()
        if exit_code != 0:
            utils.echo("Cancelling update...")
            utils.echo(
                "It seems like you have unstaged changes in the 'orchest'"
                " repository. Please commit or stash them as 'orchest update'"
                " pulls the newest changes to the 'userdir/' using a rebase.",
                wrap=WRAP_LINES,
            )
            logger.error("Failed update due to unstaged changes.")
            return

        logger.info("Updating images:\n" + "\n".join(pulled_images))
        self.docker_client.pull_images(pulled_images, prog_bar=True, force=True)

        # Delete user-built environment images to avoid the issue of
        # having environments with mismatching Orchest SDK versions.
        logger.info("Deleting user-built environment images.")
        self.resource_manager.remove_env_build_imgs()

        # Restart the application in case the update-server invoked the
        # update, since the user called the update through the UI and
        # most likely does not want to invoke "orchest restart"
        # manually.
        if mode == "web":
            utils.echo("Update completed.")
            container_config = spec.get_container_config("reg")
            self.restart(container_config)
            return

        # Let the user know they need to restart the application for the
        # changes to take effect. NOTE: otherwise Orchest might also be
        # running a mix of containers on different versions.
        utils.echo("Don't forget to restart Orchest for the changes to take effect:")
        utils.echo("\torchest restart")
Beispiel #5
0
    def _updateserver(self):
        """Starts the update-server service."""
        logger.info("Starting Orchest update service...")

        config = {}
        container_config = spec.get_container_config("reg")
        config["update-server"] = container_config["update-server"]

        self.docker_client.run_containers(config, use_name=True, detach=True)
Beispiel #6
0
    def _updateserver(self, port: int = 8000, cloud: bool = False, dev: bool = False):
        """Starts the update-server service."""
        logger.info("Starting Orchest update service...")

        config_ = {}
        container_config = spec.get_container_config(port=port, cloud=cloud, dev=dev)
        config_["update-server"] = container_config["update-server"]

        self.docker_client.run_containers(config_, use_name=True, detach=True)
Beispiel #7
0
def dev(
    port: Optional[int] = typer.Option(
        8000, help="The port the Orchest webserver will listen on."),
    log_level: Optional[LogLevel] = typer.Option(
        None,
        "-l",
        "--log-level",
        show_default=False,
        help="Log level inside the application.",
    ),
):
    """
    Start Orchest in DEV mode.

    Starting Orchest in DEV mode mounts the repository code from the
    filesystem (and thus adhering to branches) to the appropriate paths
    in the Docker containers. This allows for active code changes being
    reflected inside the application.
    """
    container_config = get_container_config("dev")

    port_bind: dict = {
        "nginx-proxy": {
            "HostConfig": {
                "PortBindings": {
                    "80/tcp": [{
                        "HostPort": f"{port}"
                    }],
                },
            },
        },
    }
    inject_dict(container_config, port_bind, overwrite=True)

    if log_level is not None:
        logging_env = f"ORCHEST_LOG_LEVEL={log_level.value}"
        log_levels: dict = {
            "orchest-webserver": {
                "Env": [logging_env],
            },
            "orchest-api": {
                "Env": [logging_env],
            },
            "auth-server": {
                "Env": [logging_env],
            },
            "celery-worker": {
                "Env": [logging_env],
            },
        }
        inject_dict(container_config, log_levels, overwrite=False)

    logger.info("Starting Orchest in DEV mode. This mounts host directories "
                "to monitor for source code changes.")
    app.start(container_config)
Beispiel #8
0
def restart(
    mode: Mode = typer.Option(
        Mode.reg, help="Mode in which to start Orchest afterwards."
    ),
    port: Optional[int] = typer.Option(
        8000, help="The port the Orchest webserver will listen on."
    ),
):
    """
    Restart Orchest.
    """
    container_config = get_container_config(mode.value)
    port_bind: dict = {
        "nginx-proxy": {
            "HostConfig": {
                "PortBindings": {
                    "80/tcp": [{"HostPort": f"{port}"}],
                },
            },
        },
    }
    inject_dict(container_config, port_bind, overwrite=True)
    app.restart(container_config)