Esempio n. 1
0
cml = CMLBootstrap(HOST, USERNAME, API_KEY, PROJECT_NAME)

# Get User Details
user_details = cml.get_user({})
user_obj = {
    "id": user_details["id"],
    "username": "******",
    "name": user_details["name"],
    "type": user_details["type"],
    "html_url": user_details["html_url"],
    "url": user_details["url"]
}

# Get Project Details
project_details = cml.get_project({})
project_id = project_details["id"]

# Create Job
create_jobs_params = {
    "name":
    "Train Autoencoder Model " + run_time_suffix,
    "type":
    "manual",
    "script":
    "cml/train_model.py",
    "timezone":
    "America/Los_Angeles",
    "environment": {},
    "kernel":
    "python3",
Esempio n. 2
0
USERNAME = os.getenv("CDSW_PROJECT_URL").split("/")[
    6]  # args.username  # "vdibia"
API_KEY = "uuc48l0gm0r3n2mib27voxazoos65em0"
PROJECT_NAME = os.getenv("CDSW_PROJECT")

# Instantiate API Wrapper
cml = CMLBootstrap(HOST, USERNAME, API_KEY, PROJECT_NAME)

#Retrieve model access keys for models that are compared

#Champion can be either hardcoded or can be the most recent model from the day it was deployed
#mvav17o0lwb9oogg3jlh8g7wqaw99e6w
champion_ak = "mvav17o0lwb9oogg3jlh8g7wqaw99e6w"

#Challenger is the most recent model deployed today
project_id = cml.get_project({})['id']  #get project ID
deployed_models_df = pd.DataFrame(cml.get_models({}))
challenger_ak = deployed_models_df[deployed_models_df['projectId'] == project_id]\
    .sort_values("createdAt", ascending=False)['accessKey'].iloc[0]


def route_request(args):

    coin = random.randint(0, 1)

    #TODO: make this more coincise. Something messing up json
    #TODO: add more metadata about model chosen
    if coin == 0:
        r = requests.post(
            'http://modelservice.ml-2f4cffbb-91e.demo-aws.ylcu-atmi.cloudera.site/model',
            data=