Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/util/compute-states.ts
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { defineMessage } from "react-intl";67import { IntlMessage } from "./i18n/types";89// Compute related schema stuff (see compute.coffee)10//11// Here's a picture of the finite state machine defined below:12//13// ----------[closing] ------- --------- [stopping] <--------14// \|/ \|/ |15// [archived] <--> [closed] --> [opening] --> [opened] --> [starting] --> [running]16//17// [unarchiving] [pending]18// [archiving]19//20//21// The icon names below refer to font-awesome, and are used in the UI.2223export type State =24| "archived"25| "archiving"26| "closed"27| "closing"28| "opened"29| "opening"30| "pending"31| "running"32| "starting"33| "stopping"34| "unarchiving";3536// @hsy: completely unclear what this is for.37type Operation =38| "open"39| "archived"40| "unarchive"41| "start"42| "stop"43| "close"44| "closed";4546export type ComputeState = {47desc: IntlMessage; // shows up in the UI (default)48desc_cocalccom?: IntlMessage; // if set, use this string instead of desc in "cocalc.com" mode49icon: string;50display: IntlMessage;51stable?: boolean;52to: { [key in Operation]?: State };53timeout?: number;54commands: Readonly<string[]>;55};5657type ComputeStates = Readonly<{58[key in State]: ComputeState;59}>;6061// ATTN: in the frontend, all "display" and "desc" strings are translated in the components/project-state file.6263export const COMPUTE_STATES: ComputeStates = {64archived: {65desc: defineMessage({66id: "util.compute-states.archived.desc",67defaultMessage:68"Project is stored in longterm storage, and will take even longer to start.",69}),70icon: "file-archive",71display: defineMessage({72id: "util.compute-states.archived.display",73defaultMessage: "Archived", // displayed name for users74}),75stable: true,76to: {77closed: "unarchiving",78},79commands: ["unarchive"],80},8182unarchiving: {83desc: defineMessage({84id: "util.compute-states.unarchiving.desc",85defaultMessage:86"Project is being copied from longterm storage; this may take several minutes depending on how many files you have.",87}),88icon: "download",89display: defineMessage({90id: "util.compute-states.unarchiving.display",91defaultMessage: "Restoring",92}),93to: {},94timeout: 30 * 60,95commands: ["status", "mintime"],96},9798archiving: {99desc: defineMessage({100id: "util.compute-states.archiving.desc",101defaultMessage: "Project is being archived to longterm storage.",102}),103icon: "paper-plane",104display: defineMessage({105id: "util.compute-states.archiving.display",106defaultMessage: "Archiving",107}),108to: {},109timeout: 5 * 60,110commands: ["status", "mintime"],111},112113closed: {114desc: defineMessage({115id: "util.compute-states.closed.desc",116defaultMessage:117"Project is archived and needs to be decompressed, so it will take longer to start.",118}),119icon: "file-archive", // font awesome icon120display: defineMessage({121id: "util.compute-states.closed.display",122defaultMessage: "Closed", // displayed name for users123}),124stable: true,125to: {126open: "opening",127archived: "archiving",128},129commands: ["open", "move", "status", "destroy", "mintime", "archive"],130},131132opening: {133desc: defineMessage({134id: "util.compute-states.opening.desc",135defaultMessage:136"Project is being imported; this may take several minutes depending on size.",137}),138icon: "gears",139display: defineMessage({140id: "util.compute-states.opening.display",141defaultMessage: "Opening",142}),143to: {},144timeout: 30 * 60,145commands: ["status", "mintime"],146},147148closing: {149desc: defineMessage({150id: "util.compute-states.closing.desc",151defaultMessage: "Project is in the process of being closed.",152}),153icon: "download",154display: defineMessage({155id: "util.compute-states.closing.display",156defaultMessage: "Closing",157}),158to: {},159timeout: 5 * 60,160commands: ["status", "mintime"],161},162163opened: {164desc: defineMessage({165id: "util.compute-states.opened.desc",166defaultMessage: "Project is available and ready to try to run.",167}),168icon: "stop",169display: defineMessage({170id: "util.compute-states.opened.display",171defaultMessage: "Stopped",172}),173stable: true,174to: {175start: "starting",176close: "closing",177},178commands: [179"start",180"close",181"save",182"copy_path",183"mkdir",184"directory_listing",185"read_file",186"network",187"mintime",188"disk_quota",189"compute_quota",190"status",191"migrate_live",192"ephemeral_state",193"ephemeral_disk",194],195},196197pending: {198desc_cocalccom: defineMessage({199id: "util.compute-states.pending.desc_cocalccom",200defaultMessage:201"Finding a place to run your project. If nothing becomes available, reduce RAM or CPU, pay for members only hosting, or contact support.",202}),203desc: defineMessage({204id: "util.compute-states.pending.desc",205defaultMessage:206"Finding a place to run your project. If nothing becomes available, contact your administrator.",207}),208icon: "times-rectangle",209display: defineMessage({210id: "util.compute-states.pending.display",211defaultMessage: "Pending",212}),213stable: true,214to: {215stop: "stopping",216},217commands: ["stop"],218},219220starting: {221desc: defineMessage({222id: "util.compute-states.starting.desc",223defaultMessage: "Project is starting up.",224}),225icon: "flash",226display: defineMessage({227id: "util.compute-states.starting.display",228defaultMessage: "Starting",229}),230to: {},231timeout: 60,232commands: [233"save",234"copy_path",235"mkdir",236"directory_listing",237"read_file",238"network",239"mintime",240"disk_quota",241"compute_quota",242"status",243],244},245246stopping: {247desc: defineMessage({248id: "util.compute-states.stopping.desc",249defaultMessage: "Project is stopping.",250}),251icon: "hand-stop",252display: defineMessage({253id: "util.compute-states.stopping.display",254defaultMessage: "Stopping",255}),256timeout: 60,257to: {},258commands: [259"save",260"copy_path",261"mkdir",262"directory_listing",263"read_file",264"network",265"mintime",266"disk_quota",267"compute_quota",268"status",269],270},271272running: {273desc: defineMessage({274id: "util.compute-states.running.desc",275defaultMessage: "Project is running.",276}),277icon: "run",278display: defineMessage({279id: "util.compute-states.running.display",280defaultMessage: "Running",281}),282stable: true,283to: {284stop: "stopping",285},286commands: [287"stop",288"save",289"address",290"copy_path",291"mkdir",292"directory_listing",293"read_file",294"network",295"mintime",296"disk_quota",297"compute_quota",298"status",299"migrate_live",300],301},302} as const;303304305