spinn_utilities.data package

Module contents

class spinn_utilities.data.UtilsDataView[source]

Bases: object

A read only view of the data available at each level

All methods are class methods so can be accessed directly without instantiating a view. There is a stack of subclasses such as MachineDatView, FecDataView, SpynnakerDataView (and more). All inherit all methods. We reserve the right to override methods defined in one View in subclasses.

There are also Writer classes which override the Views but these are specifically designed to only be usable in unittests and by the simulator (ASB) directly.

You should use the data view most appropriate to what you are doing i.e. If you are accessing it from a class or function in FEC, use FecDataView but if you are accessing it from Spynnaker, use SpynnakerDataView. This will ensure that any changes to the view local to the code will affect all code in that package

The objects accessed this way should not be changed or added to. Changing or adding to any object accessed is unsupported as bypasses any check or updates done in the writer(s). Objects returned could be changed to immutable versions without notice!

The get… methods will either return a valid value or raise an Exception if the data is currently not available. The get methods will will not return None unless specifically documented to do so. As a reasonable effort is made the setters to verify the data types, the get methods can be expected to return the correct type.

There are also several semantic sugar get.. methods. Some are slightly faster but many are just to make the code more readable. Some semantic sugar methods do not start with get to keep the same name as the existing function on the object has.

The iterate… methods offer a view over the collections within mutable data objects, particularly ones changed between runs. There is no guarantee if the returned iterator will or will not reflect any changes to the underlying data object, nor that how a method behaves in this way does not change over time. So the methods should be called for every iteration.

Each iterate.. method will have a corresponding get_n.. which you need to do instead of len(iterate..) as we reserve the right to make any iterate method return an iterable which does not support len without notice.

add… methods allow for the scripts directly or indirectly to add extra values. They allow the view to add extra safetly such as type checking. They will raise an exception if called while the simulator is running.

The has… methods will return True if the value is known and False if not. Semantically they are the same as checking if the get raises an exception. They may be faster if the object needs to be generated on the fly or protected to be made immutable. Has methods have been added where needed. More can easily be added if required.

The is… methods will return a bool value to say teh simulator is in the expected state. They may throw an exception if called at an unexpected time. For example if called before sim.setup or after sim.end

While how and where the underpinning DataModel(s) store data can change without notice, methods in View classes can be considered a supported API

classmethod check_user_can_act()[source]

Checks if the status is such that users can be making calls

This does NOT error in the Mocked state

Raises:
classmethod check_valid_simulator()[source]

Throws an error if there is no simulator

Raises:
classmethod get_executable_finder()[source]

The ExcutableFinder object created at time code is imported

Return type:ExcutableFinder
classmethod get_executable_path(executable_name)[source]

Finds an executable within the set of folders. The set of folders is searched sequentially and the first match is returned.

Semantic sugar for get_executable_finder().get_executable_path

Parameters:executable_name (str) – The name of the executable to find
Returns:The full path of the discovered executable
Return type:str
Raises:KeyError – If no executable was found in the set of folders
classmethod get_executable_paths(executable_names)[source]

Finds each executables within the set of folders.

The names are assumed to be comma separated The set of folders is searched sequentially and the first match for each name is returned.

Names not found are ignored and not added to the list.

Semantic sugar for get_executable_finder().get_executable_paths

Parameters:executable_names (str) – The name of the executable to find. Assumed to be comma separated.
Returns:The full path of the discovered executable, or None if no executable was found in the set of folders
Return type:list(str)
classmethod get_report_dir_path()[source]

Returns path to existing reports directory

..note: In unittest mode this returns a tempdir shared by all path methods

Rtpye:str
Raises:SpiNNUtilsException – If the simulation_time_step is currently unavailable
classmethod get_requires_data_generation()[source]

Reports if data generation is required

Set to True at the start and by any change that could require data generation or mapping Remains True during the first run after a data change Only set to False at the END of the first run

Return type:bool
classmethod get_requires_mapping()[source]

Reports if mapping is required

Set to True at the start and by any change that could require any mapping stage to be called Remains True during the first run after a requires mapping. Only set to False at the END of the first run

Return type:bool
classmethod get_run_dir_path()[source]

Returns the path to the directory that holds all the reports for run

This will be the path used by the last run call or to be used by the next run if it has not yet been called.

..note: In unittest mode this returns a tempdir shared by all path methods

Rtpye:str
Raises:SpiNNUtilsException – If the run_dir_path is currently unavailable
classmethod is_hard_reset()[source]

Check if the system has been hard reset since the last run finished.

Critically during the first run after reset this continues to return True!

Returns False after a reset that was considered soft.

Return type:bool
classmethod is_no_stop_requested()[source]

Checks that a stop request has not been sent

Return type:bool
Raises:NotImplementedError – If this is called from an unexpected state
classmethod is_ran_ever()[source]

Check if the simulation has run at least once, ignoring resets

Return type:bool
Raises:NotImplementedError – If this is called from an unexpected state
classmethod is_ran_last()[source]

Checks if the simulation has run and not been reset.

Rytpe:bool
Raises:NotImplementedError – If this is called from an unexpected state
classmethod is_reset_last()[source]

Reports if sim.reset called since the last sim.run

Unlike is_soft_reset and is_hard_reset this method return False during any sim.run

It also returns False after a sim.stop or sim.end call starts

Rytpe:bool
Raises:NotImplementedError – If this is called from an unexpected state
classmethod is_running()[source]

Checks if there is currently a simulation running

That is a call to run has started but not yet stopped,

Return type:bool
classmethod is_setup()[source]

Checks to see if there is already a simulator

Return type:bool
Raises:NotImplementedError – If this is called from an unexpected state
classmethod is_shutdown()[source]

Determines if simulator has already been shutdown

This returns False in the Mocked state

Rtpye:bool
classmethod is_soft_reset()[source]

Check if the system has been soft_reset since the last run finished.

Critically during the first run after reset this continues to return True!

Returns False after a reset that was considered hard.

Return type:bool
classmethod is_stop_already_requested()[source]

Checks if there has already been a request stop

Also checks the state is such that a stop request makes sense.

Returns:

True if the stop has already been requested or if the system is stopping or has already stopped False if the stop request makes sense.

Return type:

bool

Raises:
classmethod is_user_mode()[source]

Determines if simulator is currently not running so user is accessing data

This returns False in the Mocked state

Rtpye:bool
Raises:NotImplementedError – If the data has not yet been settup or on an unexpected run_status
classmethod register_binary_search_path(search_path)[source]

Register an additional binary search path for executables.

semantic sugar for executable_finder.add_path

Parameters:search_path (str) – absolute search path for binaries
classmethod set_requires_data_generation()[source]

Sets requires_data_generation to True

Only the end of a run can set it to False

classmethod set_requires_mapping()[source]

Sets requires_mapping and requires_data_generation to True

Only the end of a run can set it to False