def check_arguments_notebook(self, args): append_options_to_list(args, ["sources", "pip_installs"]) assert args.notebook or args.interactive, "must specify a notebook name unless in interactive mode" if not args.job_name: assert args.notebook or args.interactive, "must specify a notebook if no job name defined" args.job_name = os.path.splitext(os.path.basename( args.notebook))[0] + "_" + randstr( ).hex if args.notebook else "jupyter_server_{}".format( randstr().hex) if args.interactive and not args.token: __logger__.warn("no authentication token is set") args.pip_installs = args.pip_installs + ["jupyter"] args.sources = args.sources + [args.notebook]
def check_arguments_notebook(self, args): self.check_essentials(args) assert args.notebook or args.interactive, "must specify a notebook name unless in interactive mode" if not args.job_name: assert args.notebook or args.interactive, "must specify a notebook if no job name defined" args.job_name = os.path.splitext(os.path.basename(args.notebook))[ 0] + "_" + randstr().hex if args.notebook else "jupyter_server_{}".format(randstr().hex) if args.interactive and not args.token: __logger__.warn("no authentication token is set")
def submit_notebook( job: Job, cluster_alis: str, nb_file: str, image: str, workspace: str, # cluster related interactive_mode: bool=True, token: str="abcd", # notebook only gpu: int=0, cpu: int=1, memoryMB: int=10240, ports: dict={}, # resources related **kwargs ): job_name = os.path.splitext(os.path.basename(nb_file))[0] + "_" + randstr().hex job.from_notebook(nb_file, image, interactive_mode, token, gpu=gpu, cpu=cpu, memoryMB=memoryMB, ports=ports) job.decorate(cluster_alis, workspace) return job
def check_essentials(self, args): args.sources = [] if not args.sources else args.sources args.pip_installs = [] if not args.pip_installs else args.pip_installs if args.sources: assert args.workspace, "must specify --workspace if --sources used" for s in args.sources: assert os.path.isfile(s), "file %s not found" % s assert args.image, "must specify a docker image" if args.job_name: args.job_name = args.job_name.replace("$", randstr().hex)
def check_arguments_sub(self, args): append_options_to_list(args, ["sources", "pip_installs"]) if args.sources or args.pip_installs: if not args.enable_sdk: __logger__.warn( "upload local file requires --enable-sdk, assert automatically" ) args.enable_sdk = True if args.sources: assert args.workspace, "must specify --workspace if --sources used" for s in args.sources: assert os.path.isfile(s), "file %s not found" % s assert args.image, "must specify a docker image" args.job_name = args.job_name.replace("$uuid$", randstr().hex)