LogoLogo
  • Seahaven
    • Seahaven Documentation
      • Setup Your Account
      • Getting Started
        • Prepare Your Models
          • Name Objects
          • Add Camera Curve to a scene
        • Import 3D Assets
        • Colormap Editor
        • Relationship Editor
          • Start Workflow
            • Workflow
            • Relationship
              • Relationship (Array)
          • Relationships
            • Placements
            • Locate
            • Rotate
            • Neighbour
            • Drop
            • Center
            • Scale
            • Align
            • Attach
            • Put
        • Simulation Editor
          • Workflow
            • Category Visibility Threshold
          • Scene
            • 3D Asset
            • HDRI Lighting
            • Physical Sun/Sky
            • Ground Plane
            • Interior Scene
            • Room Type
          • Relationships
            • Load Relationships
          • Camera
            • Camera Configuration
            • Animated Track Camera
            • Curve-Based Camera
            • Room-Perimeter Camera
              • Category
            • Room-Based Camera
              • Additional Cameras
            • Position Camera
              • Conical
              • Spherical
              • Cubic
            • Orientation
              • Calculate Area of Interest
              • Point
            • Perspectival Camera Properties
            • Fisheye Camera Properties
          • Manipulators
            • Camera Manipulators
              • Override Camera Target
              • Override Camera Position
              • Near IR (Approximation)
              • Track Camera to Object
                • Camera Path Settings
            • Light Manipulators
              • Randomize HDRI Background
              • Modify Light Strength
              • Place Lights
                • Light Object (Bbox)
                • Light Object (Polar)
            • Material Manipulators
              • Randomize Material Color
              • Randomize Material Properties
              • Swap Materials
                • Import Material
                • Replace Material
                • Weighted Material
            • Delete Objects by Name
            • Pose Objects
              • Pose Set
              • Pose Pair
            • Constrain Object
            • Add Particle System
            • Load Object Along Curve
            • Replace
              • View settings
              • Load child object
          • Output
            • Additional Annotation Settings
            • Color Map
            • Camera Ex/Intrinsics
            • Keypoints
            • Normal Map
            • Depth Map
          • Post-Processing
            • Visualize COCO Annotations
            • Shot Noise
            • Glare
            • Disable shadows
        • Running Simulation
        • Save and Import
    • Seahaven Tutorials
    • Errors and Alerts
  • Simulation Manager
    • Simulation Manager
  • Simulation API
    • Simulation Structure
      • Sample Configuration
    • Modules
      • Structure Modules
        • Generator Class
          • generator.Room
            • Submodule: RoomTextureLoader
            • Submodule: RoomLightLoader
            • How To Query Room Properties
            • Sample Room Configuration
        • Loader Class
          • loader.ObjectLoader
      • Placement Modules
        • Placement Class
          • placement.PlacementHandler
            • Placement Rules
              • Settings
      • Lighting Modules
        • Lighting Class
          • lighting.HdriLoader
          • lighting.LightLoader
      • Camera Modules
        • Camera Class
          • camera.CameraSampler
          • camera.RoomCamera
            • Submodule: proximity_checks
            • Submodule: default_cam_param
      • Output Modules
        • Renderer Class
          • renderer.MultiRenderer
            • Submodule: RgbRenderer
            • Submodule: InstanceRenderer
            • Submodule: SemanticRenderer
            • Submodule: DepthRenderer
            • Submodule: BoundingBoxWriter
  • Management API
    • RESTful API
    • Python API
      • Example
    • Python API (V4 - BETA)
      • Installation
      • Merge Datasets
      • Methods
      • Dataset Analysis
      • Compression Artifacts
      • Domain Matching
      • Credentials
  • API Tutorials
    • Residential Interior Simulation
      • Upload Your Placement Rules
      • Modifying Your Camera
      • Modify Placement Rules
      • Run your Simulation
      • Tutorial Materials
        • Pipeline Configuration
        • Placement Rules
          • bedroom1.yaml
          • bedroom2.yaml
          • livingroom.yaml
          • floorPlan.yaml
Powered by GitBook
On this page
  • Install
  • Create a simulation object
  • Working with already running simulations
  • Create a simulation
  • Start your simulation
  • Dequeue your simulation
  • Get your simulation status
  • Get Dataset Items
  • Stop a simulation
  • Add relationship and colormap files
  • List all simulations
  • Download data
  • Track Organization Resources
  • Get Organization Simulations
  • Multi-Threaded Download
  • Delete Simulation
Export as PDF
  1. Management API

Python API

Lexset has a python package available that can be used to interact with our RESTful API

Install

You can install the python package with a simple pip install. The most recent version is 3.5.0 please be sure you have the most recent version.

pip install lexsetAPI

Create a simulation object

The python package will create a class for each simulation you start. You can use that class to keep track of your data and your simulation's progress.

import lexsetAPI as lexset

token = "Bearer token"
SimulationConfig = "Path to your pipeline config"
numberOfImages = 1000 #The number of data points you want your simulation to generate
userID = 3
nodes = 5
simulationName = "name your simulation"
simulationDescription = "Description of your simulation"
randomSeed = 1

mySimulation = lexset.simulation(token,SimulationConfig,numberOfImages,userID,nodes,simulationName,simulationDescription,randomSeed)

It is also possible to use the python API without creating a class for a simulation. This is necessary if you have already started the simulation via the GUI. You can download, start and stop simulations as well as list all active simulations this way.

Working with already running simulations

If a simulation is already running or "active" you can use the class activateSimulation to easily manage the data associated with your simulation.

mySimulation = lexset.activateSimulation(simulationID,userID,token)

Create a simulation

Once you have created your simulation you then need to send your config to Lexset and create a simulation that you can run on our servers.

mySimulation.createSimulation()

This will send the config to our severs and return your user ID, simulation ID and Dataset ID so that you can work with your data as well as start and stop your simulation.

print(mySimulation.dataID) #get your dataset ID
print(mySimulation.simID)  #get your Simulation ID
print(mySimulation.userID) #get your user ID

Start your simulation

Once you have created a simulation you can then start the simulation and begin collecting data.

mySimulation.startSimulation()

If you create a simulation through the GUI you can start it with the following command.

lexset.start(simulationID, token)

Dequeue your simulation

lexset.dequeue(simulationID,token)

Get your simulation status

If a simulation is complex it might take a long time to run and it may be necessary to check the status periodically.

mySimulation.getStatus()

You can also use getProgress() to print how much of the dataset has been generated as a percentage.

mySimulation.getProgress()

Once you have run this function you can check to see if it is complete or still running.

mySimulation.isComplete

Get Dataset Items

Once your simulation is running and generating data you can check all the datapoints and preview images. To get a full list of all the data generated so far you can use the following.

mySimulation.getDatasetItems()

That will return a list of dataset items rendered so far

[
    {
        "id": 7888,
        "renderjobid": 269,
        "datasetid": 303,
        "renderType": "rgb",
        "filename": "e3c7fb5e-3ab6-4b28-ad6c-811d16a12c01.rgb_0001.png",
        "width": 1920,
        "height": 1080,
        "dateCreated": "04 23 2021 14:53:06",
        "failed": false,
        "endTime": "2021-04-23T14:55:24",
        "startTime": "2021-04-23T14:53:06"
    },
    {
        "id": 7889,
        "renderjobid": 269,
        "datasetid": 303,
        "renderType": "rgb",
        "filename": "44ed74ed-fd60-439b-8dbb-ccf46f7cfa9f.rgb_0001.png",
        "width": 1920,
        "height": 1080,
        "dateCreated": "04 23 2021 14:53:14",
        "failed": false,
        "endTime": "2021-04-23T14:55:30",
        "startTime": "2021-04-23T14:53:14"
    },
    {
        "id": 7890,
        "renderjobid": 269,
        "datasetid": 303,
        "renderType": "seg",
        "filename": "e3c7fb5e-3ab6-4b28-ad6c-811d16a12c01.seg_0001.exr",
        "width": 1920,
        "height": 1080,
        "dateCreated": "04 23 2021 14:55:26",
        "failed": false,
        "endTime": "2021-04-23T14:55:43",
        "startTime": "2021-04-23T14:55:26"
    }
]

You can access the dataset items with this

mySimulation.dataSetItems
#You can also access specific items in the array with
firstSim.dataSetItems[1]

You can also get your progress with the following function.

mySimulation.getProgress()

Stop a simulation

In some situations you might want to stop a simulation early.

mySimulation.stopSimulation()

If you create a simulation through our GUI you can stop with the following command.

lexset.stop(simulationID,token)

Add relationship and colormap files

You can also add relationships and colormaps via our API.

#relationship
lexset.addRule(3,"D:/path/file.yaml",token)
#colormap
lexset.addColorMap(3,"D:/path/file.yaml",token)

List all simulations

If you are running multiple simulations it may be necessary for you get a list of all the simulations.

mySimulation.getSimulations()

If you created your simulation using the GUI you can access a list of simulations as follows.

lexset.listSimulations(userID,token)

Download data

Once your simulation is complete, or after you have forced it to stop, you can download the dataset. You can get an archive to download with the following.

#create the archive
mySimulation.downloadData()
#get the archive URL
mySimulation.datasetURL

It is also possible to download data directly by acquiring your dataset id. You can capture the Dataset id with the getDatasetID() function. Example:

datasetID = lexset.getDatasetID(simulationID,token)
lexset.download(datasetID,token)

//you can also set an optional argument to configure your local filename and directory

lexset.download(datasetID,token, localPath = "NONE")

Track Organization Resources

If you have an enterprise account you will want to track resources being used across all user accounts. You can get the total number of active nodes with the following command.

lexset.getComputeResources(user_id,token)

Get Organization Simulations

Return a list of all simulations created across your organization (enterprise accounts only)

Possible States:

  • RUNNING- a list of all running simulations

  • COMPLETED - a list of completed simulations

  • CREATED- a list of created simulations

  • QUEUED - a list of all simulations currently in the queue

lexset.getOrganizationSimulations(ORGANIZATION-ID,STATE,TOKEN)

This endpoint requires an organization id. Your organization ID is available on your account page.

Multi-Threaded Download

This operation is designed for large datasets. The operation will break your zip archive into multiple parts and download each on a separate thread. You can define the number of threads you want to use with the "workers" argument.

download_multiThread(<SIMULATION ID>,<TOKEN>,"<PATH>.zip",<WORKERS>)

Delete Simulation

You can also delete a simulation using the API through the delete simulation endpoint.

delete_simulation(<SIMULATION ID>,<TOKEN>)
PreviousRESTful APINextExample

Last updated 1 year ago

Please note that your simulation will first be added to the simulation queue and will be started as soon as resources are available in your account. For more information on the queue please refer to the documentation for the .

If your simulation is currently in the queue, you can remove it from the queue and place it in a ready state as follows. Please refer to the for more information on simulation states.

simulation manager
simulation manager documentation