Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main(model_name, model_version, application_name, hydrosphere_uri, *args, **kwargs):
logger.info(f"Referencing existing model `{model_name}:{model_version}`")
model = sdk.Model.from_existing(model_name, model_version)
logger.info(f"Creating singular application `{application_name}`")
application = sdk.Application.singular(application_name, model)
logger.info(f"Applying application to the cluster `{hydrosphere_uri}`")
result = application.apply(hydrosphere_uri)
logger.info(pprint.pformat(result))
import argparse
import os
from hydrosdk import sdk
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--model-version', required=True)
parser.add_argument('--model-name', required=True)
parser.add_argument('--hydrosphere-address', required=True)
args = parser.parse_args()
app_name = f'{args.model_name}-app'
model = sdk.Model.from_existing(args.model_name, args.model_version)
application = sdk.Application.singular(app_name, model)
result = application.apply(args.hydrosphere_address)
print(result, flush=True)
from hydrosdk import sdk
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--model-version', required=True)
parser.add_argument('--model-name', required=True)
parser.add_argument('--application-name-postfix', required=True)
parser.add_argument('--hydrosphere-address', required=True)
parser.add_argument('--dev', help='Flag for development purposes', action="store_true")
args = parser.parse_args()
application_name = f"{args.model_name}{args.application_name_postfix}"
model = sdk.Model.from_existing(args.model_name, args.model_version)
application = sdk.Application.singular(application_name, model)
result = application.apply(args.hydrosphere_address)
print(result, flush=True)
with open("./application_name.txt" if args.dev else "/application_name.txt", "w+") as file:
file.write(application_name)
with open("./application_link.txt" if args.dev else "/application_link.txt", "w+") as file:
file.write(urllib.parse.urljoin(args.hydrosphere_address, f"applications/{application_name}"))