Skip to content

Project#

lit.sdk.project #

This module provides a data structure and utility function for managing project-related data.

Project #

Bases: TypedDict

Represents a project with associated metadata and events.

Extra fields may be embedded within this object, with the use of add_property and remove_property.

events instance-attribute #

A list of events associated with the project.

feature instance-attribute #

A list of feature strings related to the project.

host instance-attribute #

The host where the project is located.

isArchived instance-attribute #

A flag indicating whether the project is archived.

name instance-attribute #

The name of the project.

path instance-attribute #

The file system path to the project.

raw instance-attribute #

A list of raw data strings related to the project.

ProjectEvent #

Bases: TypedDict

Represents an event in a project's history.

detail instance-attribute #

A detailed description of the event.

timestamp instance-attribute #

The UNIX timestamp of when the event occurred.

type instance-attribute #

The type of the event (e.g., "update", "creation").

username instance-attribute #

The username of the person who triggered the event.

ProjectFeatureDemo #

Bases: TypedDict

Represents a feature demonstration within a project, containing the return data of the feature and any UI guidance hints.

data instance-attribute #

The output data from testing the feature on the project.

hints instance-attribute #

Guidance provided to the UI, which can either be a list of dictionaries or a dictionary.

timestamp instance-attribute #

The timestamp corresponding to the time of the data within the project.

add_property(team_name, project_name, noun, item) #

Adds a property to the specified project within a team.

Parameters:

Name Type Description Default
team_name str

The name of the team.

required
project_name str

The name of the project to which the property will be added.

required
noun str

The name of the property to add.

required
item str

The value of the property to add.

required

Returns:

Type Description
Project

The updated project data.

Examples:

>>> add_property("contoso", "my_new_project", "noun", "item")
{'name': 'my_new_project',
 'raw': [],
 'feature': [],
 'events': [{'type': 'Added Noun',
             'detail': 'item',
             'timestamp': 1723758662.649423,
             'username': 'eyoung'},
            {'type': 'init',
             'detail': 'began work on my_new_project',
             'timestamp': 1719518129.268759,
             'username': 'eyoung'}],
 'isArchived': False,
 'noun': ['item'],
 'path': '/data/contoso/projects/my_new_project.json',
 'host': 'bogdan'}

archive(team_name, project_name) #

Archives the specified project within a team.

If the project is successfully archived, the project data is returned. If the project is not found, a RuntimeError is raised.

Parameters:

Name Type Description Default
team_name str

The name of the team.

required
project_name str

The name of the project to archive.

required

Returns:

Type Description
dict

The archived project data.

Raises:

Type Description
RuntimeError

If the project is not found.

Examples:

>>> archive("contoso", "my_new_project")
{'name': 'my_new_project',
 'raw': [],
 'feature': [],
 'events': [{'type': 'Removed Noun',
             'detail': 'item',
             'timestamp': 1723760914.278845,
             'username': 'eyoung'},
            {'type': 'Added Noun',
             'detail': 'item',
             'timestamp': 1723758662.649423,
             'username': 'eyoung'},
            {'type': 'init',
             'detail': 'began work on my_new_project',
             'timestamp': 1719518129.268759,
             'username': 'eyoung'}],
 'isArchived': False,
 'noun': []}

demo(team_name, project_name, feature_path, index, params) #

Runs a feature demonstration on the specified project and returns the result.

Parameters:

Name Type Description Default
team_name str

The name of the team.

required
project_name str

The name of the project.

required
feature_path str

The path to the feature to test.

required
index int

The data index within the project to use for the demo.

required
params dict

A set of parameters to pass to the feature script.

required

Returns:

Type Description
ProjectFeatureDemo

The result of the feature demonstration; the timestamp, return data from the feature, and any UI hints.

Examples:

>>> demo(
...     "contoso",
...     "spy",
...     "/data/contoso/features/ohlcv.py",
...     19562810,
...     {"count": 5, "size": 1, "unit": "hour"},
... )
{'timestamp': 1493994825045691315,
 'data': array([[2.38490005e+02, 2.38559998e+02, 2.33226593e+02, 2.38500000e+02,
        3.71410000e+04, 8.73224400e+06, 2.35110626e+02],
       [2.38500000e+02, 2.38660004e+02, 2.38300003e+02, 2.38520004e+02,
        2.33910000e+04, 4.86324900e+06, 2.07911118e+02],
       [2.38528900e+02, 2.38770004e+02, 2.38210007e+02, 2.38500000e+02,
        2.87640000e+04, 6.10002200e+06, 2.12071411e+02],
       [2.38500000e+02, 2.38798996e+02, 2.38399994e+02, 2.38740005e+02,
        3.50160000e+04, 7.89611100e+06, 2.25500092e+02],
       [2.39190002e+02, 2.39309998e+02, 2.38839996e+02, 2.38860001e+02,
        2.14480000e+04, 4.43271800e+06, 2.06672791e+02]]),
 'hints': {}}

estimate(team_name, project_name, feature_path, count, params) #

Estimates feature data for a specified project.

Parameters:

Name Type Description Default
team_name str

The name of the team.

required
project_name str

The name of the project.

required
feature_path str

The path to the feature script.

required
count int

The number of samples to estimate.

required
params dict

A set of parameters to pass to the feature script.

required

Returns:

Type Description
NDArray

The estimated feature data as a NumPy array.

Examples:

>>> estimate(
...     "contoso",
...     "spy",
...     "/data/contoso/features/ohlcv.py",
...     5,
...     {"count": 5, "size": 1, "unit": "hour"},
... )
array([2.43907004e+02, 2.44300000e+02, 2.43257996e+02, 2.43632999e+02,
       7.06504000e+04, 1.72431610e+07, 2.39403308e+02])

get_data(team_name, project_name, start, stop) #

Retrieves data for a specified project within a team over a given range.

This function fetches data between the start and stop indices for the given project. The returned data is either a JSON string or a dictionary. If the data is a JSON string, it is parsed into a dictionary before being returned.

Parameters:

Name Type Description Default
team_name str

The name of the team.

required
project_name str

The name of the project.

required
start int

The starting index for the data retrieval.

required
stop int

The stopping index for the data retrieval.

required

Returns:

Type Description
dict

The data for the specified project and range, parsed as a dictionary.

Raises:

Type Description
TypeError

If the returned data is not of type 'str' or 'dict'.

Examples:

>>> get_data("contoso", "spy", 0, 100)
{...}

get_data_by_date(team_name, project_name, timestamp, aperture) #

summary

Parameters:

Name Type Description Default
team_name str

The name of the team.

required
project_name str

The name of the project.

required
timestamp float

The timestamp around which data is to be retrieved.

required
aperture int

The number of samples to retrieve on either side of the timestamp.

required

Returns:

Name Type Description
dict dict

The data around the specified timestamp with the given aperture.

Examples:

>>> get_data_by_date("contoso", "spy", 1494858825, 10000)
{...}

get_sample_count(team_name, project_name) #

Retrieves the sample count for a specified project within a team.

Parameters:

Name Type Description Default
team_name str

The name of the team.

required
project_name str

The name of the project.

required

Returns:

Type Description
int

The sample count for the specified project.

Examples:

>>> get_sample_count("contoso", "spy")
52042581

initialize(team_name, project_name) #

Initializes a new project within the specified team.

Parameters:

Name Type Description Default
team_name str

The name of the team.

required
project_name str

The name of the project to initialize.

required

Returns:

Type Description
Project

The initialized project data.

Examples:

>>> initialize("contoso", "my_new_project")
{'name': 'my_new_project',
 'raw': [],
 'feature': [],
 'events': [{'type': 'init',
             'detail': 'began work on my_new_project',
             'timestamp': 1723839338.867731,
             'username': 'eyoung'}],
 'isArchived': False}

list_projects(team_name) #

Retrieves a list of projects for a specified team.

Parameters:

Name Type Description Default
team_name str

The name of the team whose projects are to be listed.

required

Returns:

Type Description
list[Project]

A list of Project dictionaries representing the projects associated with the team.

Examples:

>>> list_projects("contoso")
[{'name': 'my_new_project',
  'raw': [],
  'feature': [],
  'events': [{'type': 'init',
              'detail': 'began work on my_new_project',
              'timestamp': 1719518129.268759,
              'username': 'eyoung'}],
  'isArchived': False,
  'path': '/data/contoso/projects/my_new_project.json',
  'host': 'bogdan'},
 {'name': 'my_project',
  'raw': [],
  'feature': [],
  'events': [{'type': 'init',
              'detail': 'began work on my_project',
              'timestamp': 1719513465.104492,
              'username': 'eyoung'}],
  'isArchived': False,
  'path': '/data/contoso/projects/my_project.json',
  'host': 'bogdan'}]

remove_property(team_name, project_name, noun, item) #

Removes a property from the specified project within a team.

Parameters:

Name Type Description Default
team_name str

The name of the team.

required
project_name str

The name of the project from which the property will be removed.

required
noun str

The name of the property to remove.

required
item str

The value of the property to remove.

required

Returns:

Type Description
Project

The updated project data.

Examples:

>>> remove_property("contoso", "my_new_project", "noun", "item")
{'name': 'my_new_project',
 'raw': [],
 'feature': [],
 'events': [{'type': 'Added Noun',
             'detail': 'item',
             'timestamp': 1723758662.649423,
             'username': 'eyoung'},
            {'type': 'init',
             'detail': 'began work on my_new_project',
             'timestamp': 1719518129.268759,
             'username': 'eyoung'}],
 'isArchived': False,
 'path': '/data/contoso/projects/my_new_project.json',
 'host': 'bogdan',
 'noun': ['item']}

restore(team_name, project_name) #

Restores an archived project within a team.

If the project is successfully restored, the project data is returned. If the project is not found, a RuntimeError is raised.

Parameters:

Name Type Description Default
team_name str

The name of the team.

required
project_name str

The name of the project to restore.

required

Returns:

Type Description
dict

The restored project data.

Raises:

Type Description
RuntimeError

If the project is not found.

Examples:

>>> restore("contoso", "my_new_project")
{'name': 'my_new_project',
 'raw': [],
 'feature': [],
 'events': [{'type': 'init',
             'detail': 'began work on my_new_project',
             'timestamp': 1719518129.268759,
             'username': 'eyoung'}],
 'isArchived': False,
 'path': '/data/contoso/projects/my_new_project.json',
 'host': 'bogdan'}