spinn_utilities.make_tools package

Submodules

spinn_utilities.make_tools.check_database_keys module

spinn_utilities.make_tools.check_database_keys.check_all_log_database_keys() None[source]

This check is intended to be run after automatic_make

It will check all parallel repositories use unique database keys

spinn_utilities.make_tools.converter module

spinn_utilities.make_tools.converter.convert(src: str, dest: str, database_dir: str, database_key: str) str[source]

Converts a whole directory including sub-directories.

Parameters:
  • src – Full source directory

  • dest – Full destination directory

  • database_dir – Full path to directory to place database file in.

  • database_key – database key for this conversion

Returns:

Full path to the logs database

Raises:

ValueError

spinn_utilities.make_tools.log_sqllite_database module

class spinn_utilities.make_tools.log_sqllite_database.LogSqlLiteDatabase(database_path: str)[source]

Bases: AbstractContextManager

Specific implementation of the Database for SQLite 3.

Note

Not thread-safe on the same database. Threads can access different DBs just fine.

Note

This totally relies on the way SQLite’s type affinities function. You can’t port to a different database engine without a lot of work.

Connects to a log dict. The location of the file can be overridden using the C_LOGS_DICT environment variable.

param database_file: Full path to the database.

(use default_database_file to get the default location)

check_original(original: str) None[source]

Checks that an original log line has been added to the database.

Mainly used for testing

Parameters:

original

Raises:

ValueError – If the original is not in the database

close() None[source]

Finalises and closes the database.

classmethod deprecated_database_file() str[source]

Finds the previous database file path.

If environment variable C_LOGS_DICT exists that is used, otherwise the default path in this directory is used.

This is deprecated as any new make will no longer use this file

Returns:

Absolute path to where the database file is or will be

classmethod filename_by_key(database_dir: str, database_key: str) str[source]

Builds the file name which includes the key

Parameters:
  • database_dir – Full path to directory to place database file in.

  • database_key – key for the database

Returns:

filename including the key

Raises:

ValueError – If the key is not a single none digital character

classmethod find_databases(database_dir: str) Dict[str, str][source]

Given a directory finds the databases and keys in it.

Parameters:

database_dir – Full path to directory which may have logs databases) in it.

Returns:

Map of database_keys to full database paths.

get_directory_id(src_path: str, dest_path: str) int[source]

gets the Ids for this directory. Making a new one if needed

Parameters:
  • src_path

  • dest_path

Returns:

The ID for this directory.

get_file_id(directory_id: int, file_name: str) int[source]

Gets the id for this file, making a new one if needed.

Parameters:
  • directory_id

  • file_name

Returns:

The ID for this file

get_log_info(log_id: str) Tuple[int, str, str, str] | None[source]

Gets the data needed to replace a short log back to the original.

Parameters:

log_id – The int id as a String

Returns:

log level, file name, line number and the original text

get_max_log_id() int | None[source]
Returns:

the max id of any log message, or None it there none

classmethod key_from_filename(file_path: str) str[source]

Gets the key from the excepted filename pattern logs{key}.sqlite3

Parameters:

file_path – full path or filename in the pattern logs{key}.sqlite3

Returns:

database key

set_log_info(log_level: int, line_num: int, original: str, file_id: int) int[source]

Saves the data needed to replace a short log back to the original.

Parameters:
  • log_level

  • line_num

  • original

  • file_id

Returns:

ID for this log message

spinn_utilities.make_tools.replacer module

class spinn_utilities.make_tools.replacer.Replacer[source]

Bases: object

Performs replacements.

replace(short: str) str[source]

Apply the replacements to a short message.

Parameters:

short – The short string as read of the machine

Returns:

The message as it would if short codes where not used.

Module contents

class spinn_utilities.make_tools.FileConverter(log_database: LogSqlLiteDatabase, database_key: str)[source]

Bases: object

Converts a file. See convert().

Parameters:
  • log_database – Database to use

  • database_key – Key for this conversion

convert(src_dir: str, dest_dir: str, file_name: str) None[source]

Converts the c file changing the log messages

Parameters:
  • src_dir – Source directory

  • dest_dir – Destination directory

  • file_name – The name of the file to convert within the source directory; it will be made with the same name in the destination directory.