Result¶
A module of tuning results.
- class lorien.tune.result.Records(target_key: str, alter_key: Optional[str] = None, workload_key: Optional[str] = None)¶
The container to maintain the records of a workload.
- commit(table_name: str, nbest: int, log_file_name: Optional[str] = None, **db_kwargs)¶
Commit the records to the database. The final list in the DB will have at maximum nbest configs. If the workload has old configs, then it might have at most MAX_CONFIG_PER_ITEM configs with new and old configs.
- Parameters
table_name (str) -- The table name to commit.
nbest (int) -- The maximum number of best records to be committed.
log_file_name (Optional[str]) -- The tuning log name contains this record.
**db_kwargs -- The kwargs of boto3 client. Commonly used: "region_name='us-west-1'" or "endpoint_url=http://localhost:8000".
- static decode(record_str: str) RecordType ¶
Decode a string to a record.
- static encode(record: RecordType) str ¶
Encode a record to a string.
- static gen_record_item(record: RecordType)¶
Generate an item for a record that can be appended to the task item.
- gen_task_item() Dict[str, Any] ¶
Generate an item that can be committed to the database. Note that since all records in this container should be for the same task, they should be in the same task item.
- get_framework_build_config() Optional[Dict[str, str]] ¶
Get the framework build configurations that generate these records. If None, then the committed records will not have this information.
- peak() RecordType ¶
Peak the first record.
- pop() RecordType ¶
Pop the worst record in the container.
- push(record: RecordType)¶
Push a new record.
- Parameters
record (Any) -- The record to be pushed.
- query(table_name: str, use_alter_key: bool = False, **db_kwargs)¶
Querying the DB and update records.
- Parameters
table_name (str) -- The table name to be queried.
use_alter_key (bool) -- Use the alternative key instead of target key to query.
**db_kwargs -- The kwargs of boto3 client. Commonly used: "region_name='us-west-1'" or "endpoint_url=http://localhost:8000".
- Returns
items -- The best configs for the given target and primary key.
- Return type
Generator
- to_list(nbest: int = - 1) List[RecordType] ¶
Sort the record (of any layout) to be a list and return the best N.
- Parameters
nbest (int) -- The best N records to be returned. Default to return all.
- Returns
records -- The sorted list of records.
- Return type
List[RecordType]
- class lorien.tune.result.TuneErrorCode(value)¶
Error code for the tuning.
- class lorien.tune.result.TuneResult¶
The result of a tuning job.
- commit(commit_options: Dict[str, Any], workload: Optional[lorien.workload.Workload] = None, silent: bool = False)¶
Commit 1) a full tuning log to S3 bucket and 2) the best config to DynamoDB. If anything goes wrong, result error code will be updated and the error message will be attached.
- Parameters
commit_options (Dict[str, Any]) --
Result committing related options.
db
:DynamoDB options (Dict[str, str]).
table-name
:DynamoDB table name (str).
nbest
:The number of the top configs we will commit to DB (int).
commit-workload
:Commit workload to the workload table in the DB (bool).
commit-log
:A S3 folder path to upload a full tuning log. The log file will be removed after tuning if this field is unset (Optional[str]).
workload (Optional[Workload]) -- The corresponding workload. If not presented, we attempt to generate workloads from the tuning logs.
silent (bool) -- Disable logging if True. Default False.
- commit_tuning_log(workload: Optional[lorien.workload.Workload], log_file_path: str, table_name: str, nbest: int = 20, s3_log_file_path: Optional[str] = None, **db_kwargs)¶
Commit tuning results to the database.
- Parameters
workload (Optional[Workload]) -- The corresponding workload. If not presented, we attempt to generate workloads from the tuning logs.
log_file_path (str) -- The path of log file for the task.
table_name (str) -- The table name to commit.
nbest (int) -- Number of the best schedule to be committed.
s3_log_file_path (Optional[str]) -- The full log file path in S3. We will not access S3 in this function but only store the path along with the item in DynamoDB for future reference.
**db_kwargs -- The kwargs of boto3 client. Commonly used: "region_name='us-west-1'" or "endpoint_url=http://localhost:8000".
- static create_records_by_workloads(log_file_path: str, nbest: int, workload: Optional[lorien.workload.Workload] = None) Sequence[lorien.tune.result.Records] ¶
Parse the tuning log and create records by workloads.
- Parameters
log_file_path (str) -- The log file path.
nbest (int) -- The maximum number of best records to be kept.
workload (Optional[Workload]) -- The target workload. If presented, the returned map will only have one entry.
- Returns
records -- A list of created records.
- Return type
Sequence[Records]
- static gen_features(log_file_path: str, out_path: str)¶
Featurize tuning logs to be input features of the performance cost model.
- Parameters
log_file_path (str) -- The log file path. It can be a file path for a single file, or a directory of several log files.
out_path (str) -- The path to write generated features and artifacts.