rapidhouse.lib package

Submodules

rapidhouse.lib.informationdb module

class rapidhouse.lib.informationdb.InformationDb(ssh_conn, soft_name, bench_cmd, config, host='rapidhouse-db.nitkc.org', port=80)[source]

Bases: object

It is class that to use the Information-DB for RapidHouse.

Parameters:
  • ssh_conn – the SSH connection with the server of tuning target.
  • soft_name – the name of server application.
  • bench_cmd – the command of to evaluation of that the server of tuning target.
  • config – Instance of parameter.Parameter.
  • host – the hostname of the Information-DB.
  • port – the HTTP port number of the Information-DB.
get_param(count=None)[source]

Get the proper parameters.

Parameters:count (int) – the length of the parameters that you want to get. None is infinite.
Returns:the proper parameters.
post_param(param)[source]

Post the proper parameter.

Parameters:param (dictionary) – the proper param.

rapidhouse.lib.order module

Utility command

rapidhouse.lib.order.norm(vec1, vec2)[source]

Calculate the norm between lists.

Parameters:
  • vec1 (list) – a list.
  • vec2 (list) – a list.
Return type:

float

Returns:

the norm.

rapidhouse.lib.order.randint_range(ren, mini=0, maxi=65535)[source]

It is the random.randint that use round_range.

Parameters:
  • ren – the renge.
  • mini (int) – the lower limit for the random.rantint.
  • maxi (int) – the upper limit for the random.rantint.
Return type:

int

Returns:

the random number.

rapidhouse.lib.order.renge(mini=None, maxi=None)[source]

Nyanpass~. This renge is more useful than the range.

Parameters:
  • mini – the lower limit.
  • maxi – the upper limit.
Return type:

dictionary

Returns:

{‘min’: mini, ‘max’: maxi}

Raises ValueError:
 

when mini > max.

rapidhouse.lib.order.round_range(num, ren)[source]

Round the number by the renge. If you define the renge, then the return-value will be periodic. If you define only one of either min or max, then the return-value will be symmetric. If you don’t define the renge, then the return-value is always the input-value.

Parameters:
  • num – a number.
  • ren – the return-value of the renge.
Returns:

the rounded number.

rapidhouse.lib.order.run(cmd, conn=None)[source]

Execute the external command via the shell.

Parameters:
  • cmd (str) – the external command with argument.
  • conn – the SSH connection. If it is None, then will execute on the local.
Return type:

dictionary

Returns:

{‘code’: RETURN_CODE, ‘stdout’: str or None, ‘stderr’: str or None}

rapidhouse.lib.parameter module

class rapidhouse.lib.parameter.Parameter(in_file, out_file)[source]

Bases: object

This class edit the configuration file for the server application.

Parameters:
  • in_file (str) – the local PATH of the template file.
  • out_file (str) – It is the configuration file PATH for the server application which the PATH is either the remote PATH or the local PATH.
get_outfile_path()[source]

Getter for the PATH for outputting of file.

Return type:str
Returns:the PATH for outputting of file.
get_param_list()[source]

Return the list of the parameters name.

Return type:list
Returns:the list of the parameters name.
get_param_name(name)[source]

Return the proper parameter name.

Parameters:name – the parameter name that is set by the user.
Returns:the proper parameter name.
get_param_range(name)[source]

Return the range of the parameter.

Parameters:name – the key.
Returns:the range of the parameter.
reset()[source]

Reset the parameters.

set(name, value)[source]

Set the parameter.

Parameters:
  • name – the key.
  • value – the value.
write()[source]

Generate string for writing.

Return type:str
Returns:the string that the parameter is embedded.

rapidhouse.lib.parseconfig module

class rapidhouse.lib.parseconfig.ParseConfig(input)[source]

Bases: object

This class parse a template file of a configuration file for a server application.

the self.input of the instance variable is the template file for the server application. the self.abstract of the instance variable is a intermediate representation for the tuning. the self.kvv of the instance variable is a information of a parameters. the self.kvp of the instance variable is a information of the parameters for the Information-DB.

Parameters:input – the template file for the server application.
parse()[source]

Parse the configuration file.

rapidhouse.lib.rapidconfig module

class rapidhouse.lib.rapidconfig.RapidConfig(config_path)[source]

Bases: object

This class parse a configuration file for RapidHouse.

Parameters:config_path – a PATH of the configuration file.
parse()[source]

Parse the configuration file.

rapidhouse.lib.tune module

class rapidhouse.lib.tune.Tune(interface, algo, config, rc, group)[source]

This class handle a tuning.

Parameters:
  • interface – a instance of the ui.Ui.
  • algo – a reified instance of the alg.Algorithm.
  • config – a instance of the parameter.Parameter.
  • rc – a instance of the rapidconfig.RapidConfig.
  • group (tuple) – a group of a initial solutions.
cost(pop)[source]

Evaluate of a solution.

Parameters:pop (list) – the solution.
Returns:either -1 or a cost of the solution.
run()[source]

A thread of the tuning.

write(pop=None)[source]

Write out a configuration file for a server application.

Parameters:pop – a population.

rapidhouse.lib.ui module

class rapidhouse.lib.ui.Ui(rc)[source]

Bases: object

This class handle both the CUI and the GUI.

Parameters:rc – a instance of the rapidconfig.RapidConfig.
debug_print(string)[source]

Call self.__print() for debugging.

Parameters:string (str) – the string.
get_boolean(msg, test=None)[source]

Get a boolean input from a user.

Parameters:
  • msg (str) – a outputted message on the console.
  • test – for a unit-test. Unless the test is the None, then the return-value is the test.
Returns:

the boolean input-value from the user.

get_input(msg, test=None)[source]

Get a input from a user.

Parameters:
  • msg (str) – a outputted message on the console.
  • test – for a unit-test. Unless the test is the None, then the return-value is the test.
Returns:

the input-value from the user.

manager()[source]

Manage a tuning.

notice_best(best_score, pop)[source]

Call self.__notice(), and return a best score.

Parameters:
  • best_score – the best score.
  • pop – a population that having the best score.
Returns:

the best score.

notice_debug(type, contents)[source]

Give notice for debugging.

Parameters:
  • type (str) – a identifier.
  • contents (dictionary) – a result of a executed command.
notice_score(score, pop)[source]

Call self.__notice(), and return a score.

Parameters:
  • score – the score.
  • pop – a population that having the score.
Returns:

the score.

stop(*args)[source]

Stop a tuning.

Module contents