riverapi package
Submodules
riverapi.defaults module
riverapi.auth module
riverapi.logger module
-
class
riverapi.logger.
ColorizingStreamHandler
(nocolor=False, stream=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>, use_threads=False)[source] Bases:
logging.StreamHandler
-
BLACK
= 0
-
BLUE
= 4
-
BOLD_SEQ
= '\x1b[1m'
-
COLOR_SEQ
= '\x1b[%dm'
-
CYAN
= 6
-
GREEN
= 2
-
MAGENTA
= 5
-
RED
= 1
-
RESET_SEQ
= '\x1b[0m'
-
WHITE
= 7
-
YELLOW
= 3
-
colors
= {'CRITICAL': 1, 'DEBUG': 4, 'ERROR': 1, 'INFO': 2, 'WARNING': 3}
-
emit
(record)[source] Emit a record.
If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an ‘encoding’ attribute, it is used to determine how to do the output to the stream.
-
property
is_tty
-
riverapi.main module
-
class
riverapi.main.
Client
(baseurl=None, quiet=False, prefix='api')[source] Bases:
object
Interact with a River Server
-
property
apiroot
Combine the baseurl and prefix to get the complete root.
-
authenticate_request
(originalResponse)[source] Authenticate the request.
Given a response (an HTTPError 401), look for a Www-Authenticate header to parse. We return True/False to indicate if the request should be retried.
-
check
()[source] The user can run check to perform a service info, and update the prefix or baseurl if the server provides different ones.
-
check_response
(typ, r, return_json=True, stream=False, retry=True)[source] Ensure the response status code is 20x
-
do_request
(typ, url, data=None, json=None, headers=None, return_json=True, stream=False)[source] Do a request (get, post, etc)
-
download_model
(model_name, dest=None)[source] Download a model to file (e.g., pickle)
- with open(“muffled-pancake-9439.pkl”, “rb”) as fd:
- content=pickle.load(fd)
-
get
(url, data=None, json=None, headers=None, return_json=True, stream=False)[source] Perform a GET request
-
label
(label, identifier, model_name)[source] Given a label we know for a prediction after the fact (which we can look up with an identifier from the server), use the label endpoint to update the model metrics and call learn one. Note that the model_name is not technically required (it’s stored with the cached entry) however we require providing it to validate the association. If you have a label at the time of running predict you can use it then and should not need this endpoint. Also note that ground_truth of a prediction is synonymous with label here.
-
property
riverapi.utils module
riverapi.utils.fileio module
riverapi.utils.terminal module
-
riverapi.utils.terminal.
confirm_action
(question, force=False)[source] confirm if the user wants to perform a certain action
Parameters: - question (the question that will be asked) –
- force (if the user wants to skip the prompt) –
-
riverapi.utils.terminal.
confirm_uninstall
(filename, force=False)[source] confirm if the user wants to uninstall a module
Parameters: - filename (the file that will be removed) –
- force (if the user wants to skip the prompt) –
-
riverapi.utils.terminal.
get_installdir
()[source] get_installdir returns the installation directory of the application
-
riverapi.utils.terminal.
run_command
(cmd, sudo=False, stream=False)[source] run_command uses subprocess to send a command to the terminal.
Parameters: - cmd (the command to send, should be a list for subprocess) –
- error_message (the error message to give to user if fails,) –
- failed. (if none specified, will alert that command) –