idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
9,200 | def _build_wells ( self ) -> List [ Well ] : return [ Well ( self . _well_definition [ well ] , Location ( self . _calibrated_offset , self ) , "{} of {}" . format ( well , self . _display_name ) , self . is_tiprack ) for well in self . _ordering ] | This function is used to create one instance of wells to be used by all accessor functions . It is only called again if a new offset needs to be applied . |
9,201 | def _create_indexed_dictionary ( self , group = 0 ) : dict_list = defaultdict ( list ) for index , well_obj in zip ( self . _ordering , self . _wells ) : dict_list [ self . _pattern . match ( index ) . group ( group ) ] . append ( well_obj ) return dict_list | Creates a dict of lists of Wells . Which way the labware is segmented determines whether this is a dict of rows or dict of columns . If group is 1 then it will collect wells that have the same alphabetic prefix and therefore are considered to be in the same row . If group is 2 it will collect wells that have the same n... |
9,202 | def set_calibration ( self , delta : Point ) : self . _calibrated_offset = Point ( x = self . _offset . x + delta . x , y = self . _offset . y + delta . y , z = self . _offset . z + delta . z ) self . _wells = self . _build_wells ( ) | Called by save calibration in order to update the offset on the object . |
9,203 | def wells_by_index ( self ) -> Dict [ str , Well ] : return { well : wellObj for well , wellObj in zip ( self . _ordering , self . _wells ) } | Accessor function used to create a look - up table of Wells by name . |
9,204 | def rows ( self , * args ) -> List [ List [ Well ] ] : row_dict = self . _create_indexed_dictionary ( group = 1 ) keys = sorted ( row_dict ) if not args : res = [ row_dict [ key ] for key in keys ] elif isinstance ( args [ 0 ] , int ) : res = [ row_dict [ keys [ idx ] ] for idx in args ] elif isinstance ( args [ 0 ] , ... | Accessor function used to navigate through a labware by row . |
9,205 | def rows_by_index ( self ) -> Dict [ str , List [ Well ] ] : row_dict = self . _create_indexed_dictionary ( group = 1 ) return row_dict | Accessor function used to navigate through a labware by row name . |
9,206 | def columns ( self , * args ) -> List [ List [ Well ] ] : col_dict = self . _create_indexed_dictionary ( group = 2 ) keys = sorted ( col_dict , key = lambda x : int ( x ) ) if not args : res = [ col_dict [ key ] for key in keys ] elif isinstance ( args [ 0 ] , int ) : res = [ col_dict [ keys [ idx ] ] for idx in args ]... | Accessor function used to navigate through a labware by column . |
9,207 | def columns_by_index ( self ) -> Dict [ str , List [ Well ] ] : col_dict = self . _create_indexed_dictionary ( group = 2 ) return col_dict | Accessor function used to navigate through a labware by column name . |
9,208 | def next_tip ( self , num_tips : int = 1 ) -> Optional [ Well ] : assert num_tips > 0 columns : List [ List [ Well ] ] = self . columns ( ) drop_leading_empties = [ list ( dropwhile ( lambda x : not x . has_tip , column ) ) for column in columns ] drop_at_first_gap = [ list ( takewhile ( lambda x : x . has_tip , column... | Find the next valid well for pick - up . |
9,209 | def use_tips ( self , start_well : Well , num_channels : int = 1 ) : assert num_channels > 0 , 'Bad call to use_tips: num_channels==0' target_column : List [ Well ] = [ col for col in self . columns ( ) if start_well in col ] [ 0 ] well_idx = target_column . index ( start_well ) num_tips = min ( len ( target_column ) -... | Removes tips from the tip tracker . |
9,210 | def require_linklocal ( handler ) : @ functools . wraps ( handler ) async def decorated ( request : web . Request ) -> web . Response : ipaddr_str = request . headers . get ( 'x-host-ip' ) invalid_req_data = { 'error' : 'bad-interface' , 'message' : f'The endpoint {request.url} can only be used from ' 'local connection... | Ensure the decorated is only called if the request is linklocal . |
9,211 | def authorized_keys ( mode = 'r' ) : path = '/var/home/.ssh/authorized_keys' if not os . path . exists ( path ) : os . makedirs ( os . path . dirname ( path ) ) open ( path , 'w' ) . close ( ) with open ( path , mode ) as ak : yield ak | Open the authorized_keys file . Separate function for mocking . |
9,212 | def remove_by_hash ( hashval : str ) : key_details = get_keys ( ) with authorized_keys ( 'w' ) as ak : for keyhash , key in key_details : if keyhash != hashval : ak . write ( f'{key}\n' ) break else : raise KeyError ( hashval ) | Remove the key whose md5 sum matches hashval . |
9,213 | async def list_keys ( request : web . Request ) -> web . Response : return web . json_response ( { 'public_keys' : [ { 'key_md5' : details [ 0 ] , 'key' : details [ 1 ] } for details in get_keys ( ) ] } , status = 200 ) | List keys in the authorized_keys file . |
9,214 | async def add ( request : web . Request ) -> web . Response : body = await request . json ( ) if 'key' not in body or not isinstance ( body [ 'key' ] , str ) : return web . json_response ( data = { 'error' : 'no-key' , 'message' : 'No "key" element in body' } , status = 400 ) pubkey = body [ 'key' ] alg = pubkey . spli... | Add a public key to the authorized_keys file . |
9,215 | async def remove ( request : web . Request ) -> web . Response : requested_hash = request . match_info [ 'key_md5' ] new_keys : List [ str ] = [ ] found = False for keyhash , key in get_keys ( ) : if keyhash == requested_hash : found = True else : new_keys . append ( key ) if not found : return web . json_response ( da... | Remove a public key from authorized_keys |
9,216 | def log_init ( ) : fallback_log_level = 'INFO' ot_log_level = hardware . config . log_level if ot_log_level not in logging . _nameToLevel : log . info ( "OT Log Level {} not found. Defaulting to {}" . format ( ot_log_level , fallback_log_level ) ) ot_log_level = fallback_log_level level_value = logging . _nameToLevel [... | Function that sets log levels and format strings . Checks for the OT_API_LOG_LEVEL environment variable otherwise defaults to DEBUG . |
9,217 | def main ( ) : arg_parser = ArgumentParser ( description = "Opentrons robot software" , parents = [ build_arg_parser ( ) ] ) args = arg_parser . parse_args ( ) run ( ** vars ( args ) ) arg_parser . exit ( message = "Stopped\n" ) | The main entrypoint for the Opentrons robot API server stack . |
9,218 | def setup_rules_file ( ) : import shutil import subprocess rules_file = os . path . join ( os . path . abspath ( os . path . dirname ( __file__ ) ) , '..' , 'config' , 'modules' , '95-opentrons-modules.rules' ) shutil . copy2 ( rules_file , '/data/user_storage/opentrons_data/95-opentrons-modules.rules' ) res0 = subproc... | Copy the udev rules file for Opentrons Modules to opentrons_data directory and trigger the new rules . This rules file in opentrons_data is symlinked into udev rules directory |
9,219 | async def restart ( request : web . Request ) -> web . Response : async with request . app [ RESTART_LOCK_NAME ] : asyncio . get_event_loop ( ) . call_later ( 1 , _do_restart ) return web . json_response ( { 'message' : 'Restarting in 1s' } , status = 200 ) | Restart the robot . |
9,220 | async def create_virtual_environment ( loop = None ) : tmp_dir = tempfile . mkdtemp ( ) venv_dir = os . path . join ( tmp_dir , VENV_NAME ) proc1 = await asyncio . create_subprocess_shell ( 'virtualenv {}' . format ( venv_dir ) , loop = loop ) await proc1 . communicate ( ) if sys . platform == 'win32' : python = os . p... | Create a virtual environment and return the path to the virtual env directory which should contain a bin directory with the python and pip binaries that can be used to a test install of a software package . |
9,221 | def install_dependencies ( python ) -> str : import aiohttp import virtualenv_support import async_timeout import chardet import multidict import yarl import idna import pip import setuptools import virtualenv tmpdirname = python . split ( VENV_NAME ) [ 0 ] paths_raw = sp . check_output ( '{} -c "import sys; [print(p) ... | Copy aiohttp and virtualenv install locations ( and their transitive dependencies in new virtualenv so that the update server can install without access to full system site - packages or connection to the internet . Full access to system site - packages causes the install inside the virtualenv to fail quietly because i... |
9,222 | async def _start_server ( python , port , venv_site_pkgs = None , cwd = None ) -> sp . Popen : log . info ( "Starting sandboxed update server on port {}" . format ( port ) ) if venv_site_pkgs : python = 'PYTHONPATH={} {}' . format ( venv_site_pkgs , python ) cmd = [ python , '-m' , 'otupdate' , '--debug' , '--test' , '... | Starts an update server sandboxed in the virtual env and attempts to read the health endpoint with retries to determine when the server is available . If the number of retries is exceeded the returned server process will already be terminated . |
9,223 | async def install_update ( filename , loop ) : log . info ( "Installing update server into system environment" ) log . debug ( 'File {} exists? {}' . format ( filename , os . path . exists ( filename ) ) ) out , err , returncode = await _install ( sys . executable , filename , loop ) if returncode == 0 : msg = out else... | Install the update into the system environment . |
9,224 | def solve ( expected : List [ Tuple [ float , float ] ] , actual : List [ Tuple [ float , float ] ] ) -> np . ndarray : ex = np . array ( [ list ( point ) + [ 1 ] for point in expected ] ) . transpose ( ) ac = np . array ( [ list ( point ) + [ 1 ] for point in actual ] ) . transpose ( ) transform = np . dot ( ac , inv ... | Takes two lists of 3 x - y points each and calculates the matrix representing the transformation from one space to the other . |
9,225 | def apply_transform ( t : Union [ List [ List [ float ] ] , np . ndarray ] , pos : Tuple [ float , float , float ] , with_offsets = True ) -> Tuple [ float , float , float ] : extended = 1 if with_offsets else 0 return tuple ( dot ( t , list ( pos ) + [ extended ] ) [ : 3 ] ) | Change of base using a transform matrix . Primarily used to render a point in space in a way that is more readable for the user . |
9,226 | def apply_reverse ( t : Union [ List [ List [ float ] ] , np . ndarray ] , pos : Tuple [ float , float , float ] , with_offsets = True ) -> Tuple [ float , float , float ] : return apply_transform ( inv ( t ) , pos ) | Like apply_transform but inverts the transform first |
9,227 | async def _resin_supervisor_restart ( ) : supervisor = os . environ . get ( 'RESIN_SUPERVISOR_ADDRESS' , 'http://127.0.0.1:48484' ) restart_url = supervisor + '/v1/restart' api = os . environ . get ( 'RESIN_SUPERVISOR_API_KEY' , 'unknown' ) app_id = os . environ . get ( 'RESIN_APP_ID' , 'unknown' ) async with aiohttp .... | Execute a container restart by requesting it from the supervisor . |
9,228 | def connect ( self , port : str = None , options : Any = None ) : self . _hardware . connect ( port ) | Connect to the robot hardware . |
9,229 | def _load_instr ( ctx , name : str , mount : str , * args , ** kwargs ) -> InstrumentContext : return ctx . load_instrument ( name , Mount [ mount . upper ( ) ] ) | Build an instrument in a backwards - compatible way . |
9,230 | def load ( self , container_name , slot , label = None , share = False ) : if share : raise NotImplementedError ( "Sharing not supported" ) try : name = self . LW_TRANSLATION [ container_name ] except KeyError : if container_name in self . LW_NO_EQUIVALENT : raise NotImplementedError ( "Labware {} is not supported" . f... | Load a piece of labware by specifying its name and position . |
9,231 | def build ( cls , builder , * args , build_loop = None , ** kwargs ) : loop = asyncio . new_event_loop ( ) kwargs [ 'loop' ] = loop args = [ arg for arg in args if not isinstance ( arg , asyncio . AbstractEventLoop ) ] if asyncio . iscoroutinefunction ( builder ) : checked_loop = build_loop or asyncio . get_event_loop ... | Build a hardware control API and initialize the adapter in one call |
9,232 | def connect ( self , port : str = None , force : bool = False ) : old_api = object . __getattribute__ ( self , '_api' ) loop = old_api . _loop new_api = loop . run_until_complete ( API . build_hardware_controller ( loop = loop , port = port , config = copy . copy ( old_api . config ) , force = force ) ) old_api . _loop... | Connect to hardware . |
9,233 | def disconnect ( self ) : old_api = object . __getattribute__ ( self , '_api' ) new_api = API . build_hardware_simulator ( loop = old_api . _loop , config = copy . copy ( old_api . config ) ) setattr ( self , '_api' , new_api ) | Disconnect from connected hardware . |
9,234 | def get_attached_pipettes ( self ) : api = object . __getattribute__ ( self , '_api' ) instrs = { } for mount , data in api . attached_instruments . items ( ) : instrs [ mount . name . lower ( ) ] = { 'model' : data . get ( 'name' , None ) , 'id' : data . get ( 'pipette_id' , None ) , 'mount_axis' : Axis . by_mount ( m... | Mimic the behavior of robot . get_attached_pipettes |
9,235 | def unzip_update ( filepath : str , progress_callback : Callable [ [ float ] , None ] , acceptable_files : Sequence [ str ] , mandatory_files : Sequence [ str ] , chunk_size : int = 1024 ) -> Tuple [ Mapping [ str , Optional [ str ] ] , Mapping [ str , int ] ] : assert chunk_size total_size = 0 written_size = 0 to_unzi... | Unzip an update file |
9,236 | def hash_file ( path : str , progress_callback : Callable [ [ float ] , None ] , chunk_size : int = 1024 , file_size : int = None , algo : str = 'sha256' ) -> bytes : hasher = hashlib . new ( algo ) have_read = 0 if not chunk_size : chunk_size = 1024 with open ( path , 'rb' ) as to_hash : if not file_size : file_size =... | Hash a file and return the hash providing progress callbacks |
9,237 | def _find_unused_partition ( ) -> RootPartitions : which = subprocess . check_output ( [ 'ot-unused-partition' ] ) . strip ( ) return { b'2' : RootPartitions . TWO , b'3' : RootPartitions . THREE } [ which ] | Find the currently - unused root partition to write to |
9,238 | def write_file ( infile : str , outfile : str , progress_callback : Callable [ [ float ] , None ] , chunk_size : int = 1024 , file_size : int = None ) : total_written = 0 with open ( infile , 'rb' ) as img , open ( outfile , 'wb' ) as part : if None is file_size : file_size = img . seek ( 0 , 2 ) img . seek ( 0 ) LOG .... | Write a file to another file with progress callbacks . |
9,239 | def write_update ( rootfs_filepath : str , progress_callback : Callable [ [ float ] , None ] , chunk_size : int = 1024 , file_size : int = None ) -> RootPartitions : unused = _find_unused_partition ( ) part_path = unused . value . path write_file ( rootfs_filepath , part_path , progress_callback , chunk_size , file_siz... | Write the new rootfs to the next root partition |
9,240 | def _switch_partition ( ) -> RootPartitions : res = subprocess . check_output ( [ 'ot-switch-partitions' ] ) for line in res . split ( b'\n' ) : matches = re . match ( b'Current boot partition: ([23]), setting to ([23])' , line ) if matches : return { b'2' : RootPartitions . TWO , b'3' : RootPartitions . THREE } [ matc... | Switch the active boot partition using the switch script |
9,241 | def commit_update ( ) : unused = _find_unused_partition ( ) new = _switch_partition ( ) if new != unused : msg = f"Bad switch: switched to {new} when {unused} was unused" LOG . error ( msg ) raise RuntimeError ( msg ) else : LOG . info ( f'commit_update: committed to booting {new}' ) | Switch the target boot partition . |
9,242 | def get_module ( self ) : for md in SUPPORTED_MODULES : maybe_module = self . get_child_by_name ( md ) if maybe_module : return maybe_module return None | Returns the module placeable if present |
9,243 | def get_children_from_slice ( self , s ) : if isinstance ( s . start , str ) : s = slice ( self . get_index_from_name ( s . start ) , s . stop , s . step ) if isinstance ( s . stop , str ) : s = slice ( s . start , self . get_index_from_name ( s . stop ) , s . step ) return WellSeries ( self . get_children_list ( ) [ s... | Retrieves list of children within slice |
9,244 | def get_all_children ( self ) : my_children = self . get_children_list ( ) children = [ ] children . extend ( my_children ) for child in my_children : children . extend ( child . get_all_children ( ) ) return children | Returns all children recursively |
9,245 | def containers ( self ) -> list : all_containers : List = list ( ) for slot in self : all_containers += slot . get_children_list ( ) for container in all_containers : if getattr ( container , 'stackable' , False ) : all_containers += container . get_children_list ( ) return all_containers | Returns all containers on a deck as a list |
9,246 | def calculate_grid ( self ) : if self . grid is None : self . grid = self . get_wellseries ( self . get_grid ( ) ) if self . grid_transposed is None : self . grid_transposed = self . get_wellseries ( self . transpose ( self . get_grid ( ) ) ) | Calculates and stores grid structure |
9,247 | def transpose ( self , rows ) : res = OrderedDict ( ) for row , cols in rows . items ( ) : for col , cell in cols . items ( ) : if col not in res : res [ col ] = OrderedDict ( ) res [ col ] [ row ] = cell return res | Transposes the grid to allow for cols |
9,248 | def get_wellseries ( self , matrix ) : res = OrderedDict ( ) for col , cells in matrix . items ( ) : if col not in res : res [ col ] = OrderedDict ( ) for row , cell in cells . items ( ) : res [ col ] [ row ] = self . children_by_name [ '' . join ( cell ) ] res [ col ] = WellSeries ( res [ col ] , name = col ) return W... | Returns the grid as a WellSeries of WellSeries |
9,249 | def wells ( self , * args , ** kwargs ) : if len ( args ) and isinstance ( args [ 0 ] , list ) : args = args [ 0 ] new_wells = None if not args and not kwargs : new_wells = WellSeries ( self . get_children_list ( ) ) elif len ( args ) > 1 : new_wells = WellSeries ( [ self . well ( n ) for n in args ] ) elif 'x' in kwar... | Returns child Well or list of child Wells |
9,250 | def parse_device_information ( device_info_string : str ) -> Mapping [ str , str ] : error_msg = 'Unexpected argument to parse_device_information: {}' . format ( device_info_string ) if not device_info_string or not isinstance ( device_info_string , str ) : raise ParseError ( error_msg ) parsed_values = device_info_str... | Parse the modules s device information response . |
9,251 | def simulate ( protocol_file , propagate_logs = False , log_level = 'warning' ) -> List [ Mapping [ str , Any ] ] : stack_logger = logging . getLogger ( 'opentrons' ) stack_logger . propagate = propagate_logs contents = protocol_file . read ( ) if opentrons . config . feature_flags . use_protocol_api_v2 ( ) : try : exe... | Simulate the protocol itself . |
9,252 | def main ( ) : parser = argparse . ArgumentParser ( prog = 'opentrons_simulate' , description = __doc__ ) parser . add_argument ( 'protocol' , metavar = 'PROTOCOL_FILE' , type = argparse . FileType ( 'r' ) , help = 'The protocol file to simulate (specify - to read from stdin).' ) parser . add_argument ( '-v' , '--versi... | Run the simulation |
9,253 | def _command_callback ( self , message ) : payload = message [ 'payload' ] if message [ '$' ] == 'before' : self . _commands . append ( { 'level' : self . _depth , 'payload' : payload , 'logs' : [ ] } ) self . _depth += 1 else : while not self . _queue . empty ( ) : self . _commands [ - 1 ] [ 'logs' ] . append ( self .... | The callback subscribed to the broker |
9,254 | async def _update_firmware ( filename , loop ) : try : from opentrons import robot except ModuleNotFoundError : res = "Unable to find module `opentrons`--not updating firmware" rc = 1 log . error ( res ) else : if not robot . is_connected ( ) : robot . connect ( ) port = str ( robot . _driver . port ) robot . _driver .... | Currently uses the robot singleton from the API server to connect to Smoothie . Those calls should be separated out from the singleton so it can be used directly without requiring a full initialization of the API robot . |
9,255 | async def execute_module_command ( request ) : hw = hw_from_req ( request ) requested_serial = request . match_info [ 'serial' ] data = await request . json ( ) command_type = data . get ( 'command_type' ) args = data . get ( 'args' ) if ff . use_protocol_api_v2 ( ) : hw_mods = await hw . discover_modules ( ) else : hw... | Execute a command on a given module by its serial number |
9,256 | async def get_engaged_axes ( request ) : hw = hw_from_req ( request ) return web . json_response ( { str ( k ) . lower ( ) : { 'enabled' : v } for k , v in hw . engaged_axes . items ( ) } ) | Query driver for engaged state by axis . Response keys will be axes XYZABC and keys will be True for engaged and False for disengaged . Axes must be manually disengaged and are automatically re - engaged whenever a move or home command is called on that axis . |
9,257 | async def move ( request ) : hw = hw_from_req ( request ) req = await request . text ( ) data = json . loads ( req ) target , point , mount , model , message , error = _validate_move_data ( data ) if error : status = 400 else : status = 200 if ff . use_protocol_api_v2 ( ) : await hw . cache_instruments ( ) if target ==... | Moves the robot to the specified position as provided by the control . info endpoint response |
9,258 | def _move_mount ( robot , mount , point ) : carriage = robot . _actuators [ mount ] [ 'carriage' ] robot . poses = carriage . home ( robot . poses ) other_mount = 'left' if mount == 'right' else 'right' robot . poses = robot . _actuators [ other_mount ] [ 'carriage' ] . home ( robot . poses ) robot . gantry . move ( ro... | The carriage moves the mount in the Z axis and the gantry moves in X and Y |
9,259 | def _eap_check_config ( eap_config : Dict [ str , Any ] ) -> Dict [ str , Any ] : eap_type = eap_config . get ( 'eapType' ) for method in EAP_CONFIG_SHAPE [ 'options' ] : if method [ 'name' ] == eap_type : options = method [ 'options' ] break else : raise ConfigureArgsError ( 'EAP method {} is not valid' . format ( eap... | Check the eap specific args and replace values where needed . |
9,260 | def _deduce_security ( kwargs ) -> nmcli . SECURITY_TYPES : sec_translation = { 'wpa-psk' : nmcli . SECURITY_TYPES . WPA_PSK , 'none' : nmcli . SECURITY_TYPES . NONE , 'wpa-eap' : nmcli . SECURITY_TYPES . WPA_EAP , } if not kwargs . get ( 'securityType' ) : if kwargs . get ( 'psk' ) and kwargs . get ( 'eapConfig' ) : r... | Make sure that the security_type is known or throw . |
9,261 | def _check_configure_args ( configure_args : Dict [ str , Any ] ) -> Dict [ str , Any ] : if not configure_args . get ( 'ssid' ) or not isinstance ( configure_args [ 'ssid' ] , str ) : raise ConfigureArgsError ( "SSID must be specified" ) if not configure_args . get ( 'hidden' ) : configure_args [ 'hidden' ] = False el... | Check the arguments passed to configure . |
9,262 | async def status ( request : web . Request ) -> web . Response : connectivity = { 'status' : 'none' , 'interfaces' : { } } try : connectivity [ 'status' ] = await nmcli . is_connected ( ) connectivity [ 'interfaces' ] = { i . value : await nmcli . iface_info ( i ) for i in nmcli . NETWORK_IFACES } log . debug ( "Connec... | Get request will return the status of the machine s connection to the internet as well as the status of its network interfaces . |
9,263 | async def list_keys ( request : web . Request ) -> web . Response : keys_dir = CONFIG [ 'wifi_keys_dir' ] keys : List [ Dict [ str , str ] ] = [ ] for path in os . listdir ( keys_dir ) : full_path = os . path . join ( keys_dir , path ) if os . path . isdir ( full_path ) : in_path = os . listdir ( full_path ) if len ( i... | List the key files installed in the system . |
9,264 | async def remove_key ( request : web . Request ) -> web . Response : keys_dir = CONFIG [ 'wifi_keys_dir' ] available_keys = os . listdir ( keys_dir ) requested_hash = request . match_info [ 'key_uuid' ] if requested_hash not in available_keys : return web . json_response ( { 'message' : 'No such key file {}' . format (... | Remove a key . |
9,265 | async def eap_options ( request : web . Request ) -> web . Response : return web . json_response ( EAP_CONFIG_SHAPE , status = 200 ) | Get request returns the available configuration options for WPA - EAP . |
9,266 | def do_publish ( broker , cmd , f , when , res , meta , * args , ** kwargs ) : publish_command = functools . partial ( broker . publish , topic = command_types . COMMAND ) call_args = _get_args ( f , args , kwargs ) if when == 'before' : broker . logger . info ( "{}: {}" . format ( f . __qualname__ , { k : v for k , v ... | Implement the publish so it can be called outside the decorator |
9,267 | def position ( axis , hardware , cp = None ) : if not ff . use_protocol_api_v2 ( ) : p = hardware . _driver . position return ( p [ 'X' ] , p [ 'Y' ] , p [ axis ] ) else : p = hardware . gantry_position ( axis , critical_point = cp ) return ( p . x , p . y , p . z ) | Read position from driver into a tuple and map 3 - rd value to the axis of a pipette currently used |
9,268 | async def setup_hostname ( ) -> str : machine_id = open ( '/etc/machine-id' ) . read ( ) . strip ( ) hostname = machine_id [ : 6 ] with open ( '/etc/hostname' , 'w' ) as ehn : ehn . write ( f'{hostname}\n' ) LOG . debug ( "Setting hostname" ) proc = await asyncio . create_subprocess_exec ( 'hostname' , '-F' , '/etc/hos... | Intended to be run when the server starts . Sets the machine hostname . |
9,269 | def _update_pretty_hostname ( new_val : str ) : try : with open ( '/etc/machine-info' ) as emi : contents = emi . read ( ) except OSError : LOG . exception ( "Couldn't read /etc/machine-info" ) contents = '' new_contents = '' for line in contents . split ( '\n' ) : if not line . startswith ( 'PRETTY_HOSTNAME' ) : new_c... | Write a new value for the pretty hostname . |
9,270 | def get_name ( default : str = 'no name set' ) : try : with open ( '/etc/machine-info' ) as emi : contents = emi . read ( ) except OSError : LOG . exception ( "Couldn't read /etc/machine-info" ) contents = '' for line in contents . split ( '\n' ) : if line . startswith ( 'PRETTY_HOSTNAME=' ) : return '=' . join ( line ... | Get the currently - configured name of the machine |
9,271 | async def set_name_endpoint ( request : web . Request ) -> web . Response : def build_400 ( msg : str ) -> web . Response : return web . json_response ( data = { 'message' : msg } , status = 400 ) body = await request . json ( ) if 'name' not in body or not isinstance ( body [ 'name' ] , str ) : return build_400 ( 'Bod... | Set the name of the robot . |
9,272 | async def get_name_endpoint ( request : web . Request ) -> web . Response : return web . json_response ( data = { 'name' : request . app [ DEVICE_NAME_VARNAME ] } , status = 200 ) | Get the name of the robot . |
9,273 | def move ( self , point : Point ) -> 'Location' : return self . _replace ( point = self . point + point ) | Alter the point stored in the location while preserving the labware . |
9,274 | def _load_weird_container ( container_name ) : old_container_loading . load_all_containers_from_disk ( ) container = old_container_loading . get_persisted_container ( container_name ) rotated_container = database_migration . rotate_container_for_alpha ( container ) database . save_new_container ( rotated_container , co... | Load a container from persisted containers whatever that is |
9,275 | def _setup_container ( container_name ) : for meth in ( database . load_container , load_new_labware , _load_weird_container ) : log . debug ( f"Trying to load container {container_name} via {meth.__name__}" ) try : container = meth ( container_name ) if meth == _load_weird_container : container . properties [ 'type' ]... | Try and find a container in a variety of methods |
9,276 | def clear_tips ( self ) : for instrument in self . _instruments . values ( ) : if instrument . tip_attached : instrument . _remove_tip ( instrument . _tip_length ) | If reset is called with a tip attached the tip must be removed before the poses and _instruments members are cleared . If the tip is not removed the effective length of the pipette remains increased by the length of the tip and subsequent _add_tip calls will increase the length in addition to this . This should be fixe... |
9,277 | def identify ( self , seconds ) : from time import sleep for i in range ( seconds ) : self . turn_off_button_light ( ) sleep ( 0.25 ) self . turn_on_button_light ( ) sleep ( 0.25 ) | Identify a robot by flashing the light around the frame button for 10s |
9,278 | def add_instrument ( self , mount , instrument ) : if mount in self . _instruments : prev_instr = self . _instruments [ mount ] raise RuntimeError ( 'Instrument {0} already on {1} mount' . format ( prev_instr . name , mount ) ) self . _instruments [ mount ] = instrument instrument . instrument_actuator = self . _actuat... | Adds instrument to a robot . |
9,279 | def connect ( self , port = None , options = None ) : self . _driver . connect ( port = port ) self . fw_version = self . _driver . get_fw_version ( ) self . cache_instrument_models ( ) | Connects the robot to a serial port . |
9,280 | def home ( self , * args , ** kwargs ) : self . poses = self . gantry . home ( self . poses ) self . poses = self . _actuators [ 'left' ] [ 'plunger' ] . home ( self . poses ) self . poses = self . _actuators [ 'right' ] [ 'plunger' ] . home ( self . poses ) self . _previous_instrument = None self . _prev_container = N... | Home robot s head and plunger motors . |
9,281 | def move_to ( self , location , instrument , strategy = 'arc' , ** kwargs ) : placeable , coordinates = containers . unpack_location ( location ) offset = subtract ( coordinates , placeable . top ( ) [ 1 ] ) if isinstance ( placeable , containers . WellSeries ) : placeable = placeable [ 0 ] target = add ( pose_tracker ... | Move an instrument to a coordinate container or a coordinate within a container . |
9,282 | def _create_arc ( self , inst , destination , placeable = None ) : this_container = None if isinstance ( placeable , containers . Well ) : this_container = placeable . get_parent ( ) elif isinstance ( placeable , containers . WellSeries ) : this_container = placeable . get_parent ( ) elif isinstance ( placeable , conta... | Returns a list of coordinates to arrive to the destination coordinate |
9,283 | def disconnect ( self ) : if self . _driver : self . _driver . disconnect ( ) self . axis_homed = { 'x' : False , 'y' : False , 'z' : False , 'a' : False , 'b' : False } | Disconnects from the robot . |
9,284 | def get_slot_offsets ( self ) : SLOT_OFFSETS = { 'slots' : { 'col_offset' : 132.50 , 'row_offset' : 90.5 } } slot_settings = SLOT_OFFSETS . get ( self . get_deck_slot_types ( ) ) row_offset = slot_settings . get ( 'row_offset' ) col_offset = slot_settings . get ( 'col_offset' ) return ( row_offset , col_offset ) | col_offset - from bottom left corner of 1 to bottom corner of 2 |
9,285 | def get_attached_pipettes ( self ) : left_data = { 'mount_axis' : 'z' , 'plunger_axis' : 'b' , 'model' : self . model_by_mount [ 'left' ] [ 'model' ] , 'id' : self . model_by_mount [ 'left' ] [ 'id' ] } left_model = left_data . get ( 'model' ) if left_model : tip_length = pipette_config . load ( left_model , left_data ... | Gets model names of attached pipettes |
9,286 | def calibrate_container_with_instrument ( self , container : Container , instrument , save : bool ) : well = container [ 0 ] delta = pose_tracker . change_base ( self . poses , src = instrument , dst = well ) if fflags . calibrate_to_bottom ( ) : delta_x = delta [ 0 ] delta_y = delta [ 1 ] if 'tiprack' in container . g... | Calibrates a container using the bottom of the first well |
9,287 | def _begin_write ( session : UpdateSession , loop : asyncio . AbstractEventLoop , rootfs_file_path : str ) : session . set_progress ( 0 ) session . set_stage ( Stages . WRITING ) write_future = asyncio . ensure_future ( loop . run_in_executor ( None , file_actions . write_update , rootfs_file_path , session . set_progr... | Start the write process . |
9,288 | def calibrate ( self ) : if self . _driver and self . _driver . is_connected ( ) : self . _driver . probe_plate ( ) self . _engaged = False | Calibration involves probing for top plate to get the plate height |
9,289 | def disengage ( self ) : if self . _driver and self . _driver . is_connected ( ) : self . _driver . home ( ) self . _engaged = False | Home the magnet |
9,290 | def connect ( self ) : if self . _port : self . _driver = MagDeckDriver ( ) self . _driver . connect ( self . _port ) self . _device_info = self . _driver . get_device_info ( ) else : raise MissingDevicePortError ( "MagDeck couldnt connect to port {}" . format ( self . _port ) ) | Connect to the serial port |
9,291 | def reset_globals ( version = None , loop = None ) : global containers global instruments global labware global robot global reset global modules global hardware robot , reset , instruments , containers , labware , modules , hardware = build_globals ( version , loop ) | Reinitialize the global singletons with a given API version . |
9,292 | def _find_protocol_error ( tb , proto_name ) : tb_info = traceback . extract_tb ( tb ) for frame in reversed ( tb_info ) : if frame . filename == proto_name : return frame else : raise KeyError | Return the FrameInfo for the lowest frame in the traceback from the protocol . |
9,293 | def run_protocol ( protocol_code : Any = None , protocol_json : Dict [ Any , Any ] = None , simulate : bool = False , context : ProtocolContext = None ) : if not config . IS_ROBOT : simulate = True if None is context and simulate : true_context = ProtocolContext ( ) true_context . home ( ) MODULE_LOG . info ( "Generati... | Create a ProtocolRunner instance from one of a variety of protocol sources . |
9,294 | def get_ports_by_name ( device_name ) : filtered_devices = filter ( lambda device : device_name in device [ 1 ] , list_ports . comports ( ) ) device_ports = [ device [ 0 ] for device in filtered_devices ] return device_ports | Returns all serial devices with a given name |
9,295 | def serial_with_temp_timeout ( serial_connection , timeout ) : saved_timeout = serial_connection . timeout if timeout is not None : serial_connection . timeout = timeout yield serial_connection serial_connection . timeout = saved_timeout | Implements a temporary timeout for a serial connection |
9,296 | def _write_to_device_and_return ( cmd , ack , device_connection ) : log . debug ( 'Write -> {}' . format ( cmd . encode ( ) ) ) device_connection . write ( cmd . encode ( ) ) response = device_connection . read_until ( ack . encode ( ) ) log . debug ( 'Read <- {}' . format ( response ) ) if ack . encode ( ) not in resp... | Writes to a serial device . - Formats command - Wait for ack return - return parsed response |
9,297 | def write_and_return ( command , ack , serial_connection , timeout = DEFAULT_WRITE_TIMEOUT ) : clear_buffer ( serial_connection ) with serial_with_temp_timeout ( serial_connection , timeout ) as device_connection : response = _write_to_device_and_return ( command , ack , device_connection ) return response | Write a command and return the response |
9,298 | async def get_advanced_settings ( request : web . Request ) -> web . Response : res = _get_adv_settings ( ) return web . json_response ( res ) | Handles a GET request and returns a json body with the key settings and a value that is a list of objects where each object has keys id title description and value |
9,299 | async def set_advanced_setting ( request : web . Request ) -> web . Response : data = await request . json ( ) key = data . get ( 'id' ) value = data . get ( 'value' ) if key and key in advs . settings_by_id . keys ( ) : advs . set_adv_setting ( key , value ) res = _get_adv_settings ( ) status = 200 else : res = { 'mes... | Handles a POST request with a json body that has keys id and value where the value of id must correspond to an id field of a setting in opentrons . config . advanced_settings . settings . Saves the value of value for the setting that matches the supplied id . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.