gristlabs_grist-core/app/server/lib/ISandbox.ts
Paul Fitzpatrick e492dfdb22 (core) add experimental support for python3 in staging
Summary:
This adds `runsc` and `python3` to the grist-server images. For deployments with GRIST_EXPERIMENTAL_PLUGINS=1 (dev + staging but not prod) a hack is added to use `python3` under `runsc` for documents with a special title (`activate-python3-magic` or similar).

This will simplify experiments on behavior of this configuration under realistic conditions.

Hopefully, before landing this, I'll be able to switch to storing a python flag in a document options cell being added by @georgegevoian in a parallel diff, since using the doc title is super hacky :-).

Test Plan: tested manually on worker built locally

Reviewers: dsagal, alexmojaki

Reviewed By: dsagal, alexmojaki

Subscribers: georgegevoian

Differential Revision: https://phab.getgrist.com/D2998
2021-08-26 09:39:26 -04:00

33 lines
1.1 KiB
TypeScript

import * as log from 'app/server/lib/log';
/**
* Starting to whittle down the options used when creating a sandbox, to leave more
* freedom in how the sandbox works.
*/
export interface ISandboxCreationOptions {
comment?: string; // an argument to add in command line when possible, so it shows in `ps`
logCalls?: boolean;
logMeta?: log.ILogMeta;
logTimes?: boolean;
// This batch of options is used by SafePythonComponent, so are important for importers.
entryPoint?: string; // main script to call - leave undefined for default
sandboxMount?: string; // if defined, make this path available read-only as "/sandbox"
importMount?: string; // if defined, make this path available read-only as "/importdir"
docUrl?: string; // to support SELF_HYPERLINK.
preferredPythonVersion?: '2' | '3';
}
export interface ISandbox {
shutdown(): Promise<unknown>; // TODO: tighten up this type.
pyCall(funcName: string, ...varArgs: unknown[]): Promise<any>;
reportMemoryUsage(): Promise<void>;
}
export interface ISandboxCreator {
create(options: ISandboxCreationOptions): ISandbox;
}