Skip to main content

This module provides a simple Python interface to interact with the Serial API. It allows you to easily perform common operations such as uploading process data, initializing identifiers, and checking the server connection.

Project description

Overview

This module provides a partial Python SDK for interacting with Serial's API. If you need to perform actions not provided in the SDK, please reference the API documentation. If neither the API nor the library provides you with the necessary tools, please contact Serial Support. The latest version of the library can be downloaded here.

Installation

Clone the repository from GitHub or install via pip:

git clone https://https://github.com/serialmfg/serial-py.git

or

pip install serialmfg

Dependencies

This project requires the following dependencies:

  • requests

Example Usage

  1. Get an API key from your Serial account or admin.

  2. (Optionally) Generate a station ID from process builder in the serial web app. Generate Station Id

  3. Implement your script:

import serialmfg as serial

serial.set_station_id('YOUR_STATION_ID')
serial.set_api_key('YOUR_API_KEY')

# ----------- Component Instances ----------- #

# Creating a component instance
my_component_instance = serial.ComponentInstances.create(identifier="ABC-1234", component_name="Component Name") 

# Getting a component instance
my_component_instance_2 = serial.ComponentInstances.get(identifier="XYZ-5678") 

# Listing component instances
defective_components = serial.ComponentInstances.list({"status": "DEFECTIVE"}) 


# ----------- Process Entries ----------- #

# Creating a process entry
my_process_entry = serial.ProcessEntries.create(process_id="process-id", component_instance_identifier="ABC-1234") 

# Adding data to a process entry
my_process_entry.add_text(dataset_name="Foo", value="bar")
my_process_entry.add_number(dataset_name="Pi Approx", value=3.141, lsl=3.1, usl=3.2)
my_process_entry.add_boolean(dataset_name="Pass Fail Criteria", value=True, expected_value=True)
my_process_entry.add_file(dataset_name="Oven Temperatures", path="/Users/me/Downloads/oven-temp.csv", file_name="oven-temp-todays-date.csv") 
my_process_entry.add_image(dataset_name="Cat Pictures", path="/Users/me/Documents/my-cat.png", file_name="jerry.png") 
my_process_entry.add_link(dataset_name="Link Child 1", child_identifier="XYZ-5678")

# Submitting a process entry
my_process_entry.submit(cycle_time=42, is_pass=False) #Optionally add cycle_time or process result override

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

serialmfg-1.3.0.tar.gz (18.2 kB view hashes)

Uploaded Source

Built Distribution

serialmfg-1.3.0-py3-none-any.whl (22.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page