modac_utils module

modac_utils.authenticate_modac(generate_token=False)[source]

Authenticates a user on modac.cancer.gov

generate_tokenBool

Either generate a new token, or read saved token if it exists

tuple(string,string)

tuple with the modac credentials

modac_utils.get_dataObject_modac_filesize(data_object_path)[source]
Return the file size in bytes for a modac file
data_object_pathstring

The path of the file on MoDAC

integer

file size in bytes

modac_utils.get_dataObject_modac_md5sum(data_object_path)[source]
Return the md5sum for a modac file
data_object_pathstring

The path of the file on MoDAC

string

The md5sum of the file

modac_utils.get_dataObject_modac_meta(data_object_path)[source]
Return the self metadata values for a file (data_object)
data_object_pathstring

The path of the file on MoDAC

dictionary

Dictonary of all metadata for the file in MoDAC

modac_utils.get_file_from_modac(fname, origin)[source]

Downloads a file from the “Model and Data Clearning House” (MoDAC) repository. Users should already have a MoDAC account to download the data. Accounts can be created on modac.cancer.gov

fnamestring

path on disk to save the file

originstring

original MoDAC URL of the file

string

Path to the downloaded file

modac_utils.query_yes_no(question, default='yes')[source]

Ask a yes/no question via raw_input() and return their answer.

question: string

string that is presented to the user.

default: boolean

The presumed boolean answer if the user just hits <Enter>.

boolean

True for “yes” or False for “no”.

modac_utils.register_file_to_modac(file_path, metadata, destination_path)[source]

Register a file in the “Model and Data Clearning House” (MoDAC). The file size is limited to 2GBs

Parameters
  • file_path (string) – path on disk for the file to be uploaded

  • metadata (dictionary) – dictionary of attribute/value pairs of metadata to associate with the file in MoDaC

  • destination (string) – The path on MoDaC in form of collection/filename

Returns

integer – The returned code from the PUT request