Beispiel #1
0
def test_custom_run_coordinator_config(template: HelmTemplate):
    module = "a_module"
    class_ = "Class"
    config_field_one = "1"
    config_field_two = "two"
    config = {
        "config_field_one": config_field_one,
        "config_field_two": config_field_two
    }
    helm_values = DagsterHelmValues.construct(dagsterDaemon=Daemon.construct(
        runCoordinator=RunCoordinator.construct(
            enabled=True,
            type=RunCoordinatorType.CUSTOM,
            config=RunCoordinatorConfig.construct(
                customRunCoordinator=ConfigurableClass.construct(
                    module=module,
                    class_=class_,
                    config=config,
                )),
        )))
    configmaps = template.render(helm_values)
    assert len(configmaps) == 1

    instance = yaml.full_load(configmaps[0].data["dagster.yaml"])

    assert instance["run_coordinator"]["module"] == module
    assert instance["run_coordinator"]["class"] == class_
    assert instance["run_coordinator"]["config"] == config
Beispiel #2
0
def test_queued_run_coordinator(instance_template: HelmTemplate, ):  # pylint: disable=redefined-outer-name
    helm_values = DagsterHelmValues.construct(dagsterDaemon=Daemon.construct(
        runCoordinator=RunCoordinator.construct(
            enabled=True,
            type=RunCoordinatorType.QUEUED,
            config=RunCoordinatorConfig.construct(
                queuedRunCoordinator=QueuedRunCoordinatorConfig.construct(
                    tagConcurrencyLimits=[
                        TagConcurrencyLimit.construct(
                            key="foo", value="hi", limit=1)
                    ]), ),
        )))

    configmaps = instance_template.render(helm_values)

    assert len(configmaps) == 1

    instance = yaml.full_load(configmaps[0].data["dagster.yaml"])

    assert instance["run_coordinator"]["class"] == "QueuedRunCoordinator"
    assert instance["run_coordinator"]["config"]["tag_concurrency_limits"] == [
        {
            "key": "foo",
            "value": "hi",
            "limit": 1
        }
    ]
Beispiel #3
0
def test_queued_run_coordinator_config(template: HelmTemplate, enabled: bool):
    max_concurrent_runs = 50
    tag_concurrency_limits = [
        TagConcurrencyLimit(key="key", value="value", limit=10)
    ]
    dequeue_interval_seconds = 50
    helm_values = DagsterHelmValues.construct(dagsterDaemon=Daemon.construct(
        runCoordinator=RunCoordinator.construct(
            enabled=enabled,
            type=RunCoordinatorType.QUEUED,
            config=RunCoordinatorConfig.construct(
                queuedRunCoordinator=QueuedRunCoordinatorConfig.construct(
                    maxConcurrentRuns=max_concurrent_runs,
                    tagConcurrencyLimits=tag_concurrency_limits,
                    dequeueIntervalSeconds=dequeue_interval_seconds,
                )),
        )))
    configmaps = template.render(helm_values)
    assert len(configmaps) == 1

    instance = yaml.full_load(configmaps[0].data["dagster.yaml"])

    assert ("run_coordinator" in instance) == enabled
    if enabled:
        assert instance["run_coordinator"][
            "module"] == "dagster.core.run_coordinator"
        assert instance["run_coordinator"]["class"] == "QueuedRunCoordinator"
        assert instance["run_coordinator"]["config"]

        run_coordinator_config = instance["run_coordinator"]["config"]

        assert run_coordinator_config[
            "max_concurrent_runs"] == max_concurrent_runs
        assert run_coordinator_config[
            "dequeue_interval_seconds"] == dequeue_interval_seconds

        assert len(run_coordinator_config["tag_concurrency_limits"]) == len(
            tag_concurrency_limits)
        assert run_coordinator_config["tag_concurrency_limits"] == [
            tag_concurrency_limit.dict()
            for tag_concurrency_limit in tag_concurrency_limits
        ]