Python - Process Lambdas

Run Process Lambda

This example runs a lambda process in the platform:

 result = vf.create_process_entity(
            project=projectId,
            type=vf.entity_type.Process,
            name="Generate Tetra Model " + strand,
            fields={
                'file_folder' : folderId,
                'code': 'estimations-generate-tetra-model.py',
                'input_value_bm_entity': raw_block_model_id,
                'input_value_bm_file': block_model_name,
                'input_value_strand': strand
            },

            crs=request.crs,
            files=['./estimations/estimations-generate-tetra-model.py'],
            callback=my_callback_url)



        if not result.success:
            print(result.error_info)
            exit(1)
        process_id = result.id

 

Read Process Results

This example shows how to read the results of a Process Lambda execution.

# The "project" variable contains the Project ID
# The "process_id" variable contains the ID for the report entity
csvdata = vf.get_file(project, process_id, 'my_result_data.csv')

Initialize Process Lambda

The following example shows how to obtain the lambda_host interface:

from voxelfarm import process_lambda

lambda_host = process_lambda.process_lambda_host()

Read inputs of Process Lambda

The following example shows how to read inputs from a process lambda program:

from voxelfarm import process_lambda

lambda_host = process_lambda.process_lambda_host()
mesh_entity = lambda_host.input_entity("mesh_entity_id", "Entity", vf.type.voxel_mesh)
string_input = lambda_host.input_string("string_input", "String Input", "")
numerical_input = lambda_host.input("numerical_input", "Numerical Input", 0.0)

Downloading files in Process Lambda

This example shows how to download all files attached to an entity:

from voxelfarm import process_lambda

lambda_host = process_lambda.process_lambda_host()
ml_files = lambda_host.download_entity_files(ml_entity)

Getting temp folder in Process Lambda

This example shows how to get the path to the large capacity temp folder used for temporary storage:

from voxelfarm import process_lambda

lambda_host = process_lambda.process_lambda_host()
scrap_folder = lambda_host.get_scrap_folder()

Attach file to Process Lambda

The following example shows how to attach a file from the temporary drive to the running process lambda entity:

from voxelfarm import process_lambda

lambda_host = process_lambda.process_lambda_host()
floor = os.path.join(scrap, 'tetra_mesh_floor.obj')
lambda_host.attach_file(floor)

 

Log from Process Lambda

The following example shows how to send a new line to the processing log:

from voxelfarm import process_lambda

lambda_host = process_lambda.process_lambda_host()
lambda_host.log('My log message here)

 

Set exit code for Process Lambda

The following example shows how to set the exit code for a Process Lambda:

from voxelfarm import process_lambda

lambda_host = process_lambda.process_lambda_host()
lambda_host.set_exit_code(0)