예제 #1
0
 def creator(num_clusters: int) -> List[Cluster]:
     fake_clusters = []
     for n in range(num_clusters):
         fake_clusters.append(
             Cluster.parse_obj({
                 "id":
                 faker.pyint(),
                 "name":
                 faker.name(),
                 "type":
                 ClusterType.ON_PREMISE,
                 "owner":
                 faker.pyint(),
                 "endpoint":
                 faker.uri(),
                 "authentication":
                 choice([
                     NoAuthentication(),
                     SimpleAuthentication(
                         username=faker.user_name(),
                         password=faker.password(),
                     ),
                     KerberosAuthentication(),
                     JupyterHubTokenAuthentication(api_token=faker.uuid4()),
                 ]),
             }))
     return fake_clusters
예제 #2
0
    async def factory() -> DaskClient:
        client = await DaskClient.create(
            app=minimal_app,
            settings=minimal_app.state.settings.DASK_SCHEDULER,
            endpoint=parse_obj_as(AnyUrl,
                                  dask_spec_local_cluster.scheduler_address),
            authentication=NoAuthentication(),
        )
        assert client
        assert client.app == minimal_app
        assert client.settings == minimal_app.state.settings.DASK_SCHEDULER
        assert client.cancellation_dask_pub
        assert not client._taskid_to_future_map
        assert not client._subscribed_tasks

        assert client.dask_subsystem.client
        assert not client.dask_subsystem.gateway
        assert not client.dask_subsystem.gateway_cluster
        scheduler_infos = client.dask_subsystem.client.scheduler_info(
        )  # type: ignore
        print(
            f"--> Connected to scheduler via client {client=} to scheduler {scheduler_infos=}"
        )
        created_clients.append(client)
        return client
예제 #3
0
def test_default_cluster(minimal_dask_config: None, client: TestClient):
    dask_scheduler_settings = client.app.state.settings.DASK_SCHEDULER
    default_cluster = DaskClientsPool.default_cluster(dask_scheduler_settings)
    assert default_cluster
    assert default_cluster.endpoint == parse_obj_as(
        AnyUrl,
        f"tcp://{dask_scheduler_settings.DASK_SCHEDULER_HOST}:{dask_scheduler_settings.DASK_SCHEDULER_PORT}",
    )
    assert default_cluster.id == dask_scheduler_settings.DASK_DEFAULT_CLUSTER_ID
    assert default_cluster.authentication == NoAuthentication()
 def default_cluster(settings: DaskSchedulerSettings):
     return Cluster(
         id=settings.DASK_DEFAULT_CLUSTER_ID,
         name="Default internal cluster",
         type=ClusterType.ON_PREMISE,
         endpoint=
         f"tcp://{settings.DASK_SCHEDULER_HOST}:{settings.DASK_SCHEDULER_PORT}",
         authentication=NoAuthentication(),
         owner=
         1,  # FIXME: that is usually the everyone's group... but we do not know nor care about it in director-v2...
     )  # type: ignore