Skip to content

Latest commit

 

History

History
130 lines (97 loc) · 2.87 KB

under-the-hood.mdx

File metadata and controls

130 lines (97 loc) · 2.87 KB
title sidebar_position
Under the hood
5
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import BrowserWindow from '@site/src/components/browser-window';

Turning code into a Datagrok script

Briefly, you only need to do the following:

  • Create a new script file in the Datagrok script editor
  • Write the code in any supported language.
  • Add header: the set of annotation comments specifying the script language, tags, input and output variables.

That's all.

Runtime environment

For each language, Datagrok uses a predefined header and creates an environment with the set of pre-installed packages.

<Tabs>
<TabItem value="python" label="Python" default>
import os
import io
import json
import pandas as pd
import requests
from datetime import datetime, timedelta
</TabItem>

<TabItem value="r" label="R">
require(httr)
require(repr)
require(data.table)
require(R.utils)
</TabItem>

<TabItem value="octave" label="Octave">

Octave scripts run in a separate container on server. This container has following Octave packages pre-installed:

Always provide pkg load %PACKAGE_NAME% in your scripts, since script runs are fully independent.

</TabItem>

<TabItem value="julia" label="Julia">
using HTTP
using DataFrames
using CSV
using Compat
using MbedTLS
using Dates
using JSON
</TabItem>

<TabItem value="javascript" label="JavaScript">
import * as grok from 'datagrok-api/grok';
import * as ui from 'datagrok-api/ui';
import * as DG from 'datagrok-api/dg';
import * as OCL from 'openchemlib/full.js';
import * as rxjs from 'rxjs';
import * as rxjs.operators from 'rxjs/operators';
import * as $ from 'cash-dom';
import * as dayjs from 'dayjs';
import * as wu from 'wu';
import * as exceljs from 'ExcelJS';
import * as html2canvas from 'html2canvas';
</TabItem>

</Tabs>

Environment isolation

You can specify an environment for the script to use, including the language version and a set of libraries.

Datagrok uses Conda as the environment management system. A Conda environment:

  • isolates each script run,
  • resolves dependencies,
  • and takes time to be created before a script run.

Later, the script uses the pre-created environment with no delay for resolving dependencies.

In Datagrok, Conda environment configuration can be specified either right inside the script, or as part of a package.

See also: