Create dataset

for this example you need the following files:

CreateDataset.py

import os

from LOGS import LOGS
from LOGS.Entities.ProjectRequestParameter import (
    ProjectRequestParameter,
    ProjectSortingOptions,
)
from LOGS.Entity.EntitySortBy import SortDirection

# Connect to LOGS
logs = LOGS()

# In this example we assume that the file is next to the script itself
file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "logspy-logo.png")

# The dataset entity differs slightly from other entities as it has to be created
# based on datasets files. Though to create a dataset object we need to specify
# these files as a list and a specific format
dataset = logs.newDataset(files=[file], formatOrFormatId="image")

# Project is not required, but it is recommended to assign the dataset to a project.
# This example assigns the newest project to the dataset.

newest_project = logs.projects(
    ProjectRequestParameter(
        sortBy=[(ProjectSortingOptions.ENTERED_ON, SortDirection.DESC)]
    )
).first()

# # Please note, that a dataset can be assigned to multiple projects. That why a list
# # has to be used for passing the project.
dataset.projects = [newest_project]

# # Create this dataset in LOGS
logs.create(dataset)

dataset.printContent(hideNone=True)