Artemis Anchors

Introduction

Artemis is integrated into code using special comments called anchors. These are comments that take this form @input number, @output heading, @doc Markdown, etc. These anchors are the building blocks of Artemis, and they are used to produce the interactive visuals, inputs, and documentation offered by Artemis.

When you run your script normally, these anchors do nothing. They are regular comments that do not affect your code. However, when you run your code using artemis_labs script.py, Artemis will scan your code and use them to automatically generate interactive elements displayed in the form of cards on the left-hand side of your Artemis window. Each card contains the interactive element, its name, and the line number associated with it:

19201920

Simple Example

Preparing your first script

Let's take a look at a simple example:

# @card title="Interface Card"
# @doc Please enter the value for a
a = 3 
# @input number data=a


# Compute 2 * a
value = 2 * a

# @card title="Interface Card"
# @doc You entererd...
# @output heading data=value

In Lines 1-4 of the code, the anchors # @card will start a new interface card, # @doc will create a piece of in-line documentation, and # @input number will create a numerical input in Artemis which overrides the value of a when the code is ran in Artemis.

In Lines 10-12 of the code, the anchors # @card will start a new interface card, # @doc will create a piece of in-line documentation, and # @output heading will create output the value of the variable value in textual form.

Running your first script

When we run this code with artemis_labs simple_example.py, our browser will look something like this

19201920

Your first input card

The card enclosed with the red dashed box was generated automatically from the anchor # @input number which we placed in your code in Line 1. This input is automatically linked to the variable a underneath it in Line 2.

You can now go ahead and enter a value into the input the value you would like to set a to, and you can press the big purple Submit button to continue.

19201920

Your first output card

Once you do so, you'll notice a new card will appear that says "Variable: value" alongside its line number and text value. This output was automatically generated by the anchor # @output heading data=value and linked to the variable value underneath it on Line 8. This card is a heading output, which is a simple textual representation of the variable.

19171917

This documentation walks through the complete set of anchors offered by Artemis alongside the many customizations offered to each anchor.

Primary Anchors

These are the primary anchors used in Artemis

Type of Anchor

Format

Purpose

Input Anchors

@input type

Generate an interactive input for a variable

Output Anchor

@output type

Display complex variables in a variety of forms, including images, tables, 3D models, graphs, and more

Documentation Anchor

@doc Text

Generate a documentation card which displays static documentation output, including markdown, latex, multimedia, evaluated python code, and more

Card Anchor

@card

Starts a new card in Artemis Interface

Stop Anchor

@stop

Stop anchor can be used to force an pause the code until Continue is pressed.

Delay Anchor

@delay

Delay anchor can be used to pause the code for a specified length of time in the code.

Inline Anchor Features

Artemis supports a number of special in-line anchor features which offer power capabilities ranging from custom code formatting to macros to embedded code snippets.

Inline Anchor

Format

Purpose

Markdown

## MarkDown

Formatted as standard Markdown

LaTeX

$$LATEX_COMMAND$$

Evaluated inline as code

Fields

%%field_name%%

Replaced with corresponding value
in config_file

Evaluated Expressions

<<expression>>

Evaluated inline as code

Linked Code

`# @linkedcode start=marker_start end=marker_end

Embeds code snippet demarcated by markers

Anchor Flags

You may alter the behavior of individual anchors using Anchor Flags. You can apply these to flags in two ways:

  1. You can apply these inline by using the syntax --custom_flag
  2. You can apply these to all anchors with a particular tag using the syntax @flag custom_flag #tag_to_disable

Anchor Tags

You can give anchors Tags by appending the tag in the form #tag to the end of the anchor. These tags are used by other commands to modify the behavior of groups of anchors with a shared tag.

Anchor Runtime Information

Artemis allows you to customize the runtime information displayed in the initial "System Information" card. You can customize this information by editing the run_information dictionary in the get_run_information() function in the config file.

750750

Artemis Runtime Settings

Artemis allows you to customize specific runtime settings which affect the behavior of Anchors

Runtime Settings

Purpose

delay

The default delay after each anchor

You can customize these runtime settings by editing the settings dictionary in the get_settings() function in the config file.

666666

Did this page help you?