@datagrok/bio 2.16.9 → 2.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,52 +0,0 @@
1
- import * as grok from 'datagrok-api/grok';
2
- import * as ui from 'datagrok-api/ui';
3
- import * as DG from 'datagrok-api/dg';
4
-
5
- import {delay} from '@datagrok-libraries/utils/src/test';
6
-
7
- import {Pepsea} from './pepsea';
8
-
9
- /** Waits if container is not started
10
- * @param {number} ms - time to wait in milliseconds */
11
- export async function awaitContainerStart(ms: number = 60000): Promise<void> {
12
- const dc = await Pepsea.getDockerContainer();
13
- await startDockerContainer(dc, ms);
14
- }
15
-
16
- export async function startDockerContainer(argDc: DG.DockerContainer, timeout: number = 60000): Promise<void> {
17
- // argDc contains current container status
18
- let dc: DG.DockerContainer | null = argDc;
19
- let end: boolean = false;
20
- for (let i = 0; i < timeout / 200; ++i) {
21
- if (dc === null) dc = await grok.dapi.docker.dockerContainers.find(argDc.id);
22
-
23
- if (isStarted(dc)) {
24
- end = true;
25
- break;
26
- }
27
-
28
- switch (dc.status) {
29
- case 'stopped': {
30
- // TODO: Use the new dockerContainers API
31
- await grok.dapi.docker.dockerContainers.run(dc.id);
32
- break;
33
- }
34
- case 'pending change':
35
- case 'changing': {
36
- // skip to wait
37
- break;
38
- }
39
- case 'error': {
40
- throw new Error('Docker container error state.');
41
- }
42
- }
43
- dc = null;
44
- await delay(200);
45
- }
46
- if (!end) throw new Error('Docker container start timeout.');
47
- // this.dc = await grok.dapi.docker.dockerContainers.find(dcId);
48
- }
49
-
50
- export function isStarted(dc: DG.DockerContainer): boolean {
51
- return dc.status === 'checking' || dc.status === 'started';
52
- }