Under the hood
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.
- Python
- R
- Octave
- Julia
- JavaScript
import os
import io
import json
import pandas as pd
import requests
from datetime import datetime, timedelta
require(httr)
require(repr)
require(data.table)
require(R.utils)
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.
using HTTP
using DataFrames
using CSV
using Compat
using MbedTLS
using Dates
using JSON
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';
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: