code: def main(args=None):
      parser = HelpfulParser(prog="lore")
      parser.add_argument(
          "--version",
          action="version",
          version="\nsystem version: %s | project version: %s"
          % (lore.__version__, env.REQUIRED_VERSION),
      )
      commands = parser.add_subparsers(help="common commands")
  
      env_parser = commands.add_parser(
          "env", help="print lore.env variables for the current project"
      )
      env_parser.set_defaults(func=print_env)
  
      init_parser = commands.add_parser(
          "init", help="create a new lore project"
      )
      init_parser.set_defaults(func=init)
      init_parser.add_argument(
          "name", metavar="NAME", help="the name of the project"
      )
      init_parser.add_argument("--git-ignore", default=True)
      init_parser.add_argument("--python-version", default=None)
      init_parser.add_argument("--bare", action="store_true")
  
      api_parser = commands.add_parser("api", help="serve the api")
      api_parser.set_defaults(func=api)
  
      console_parser = commands.add_parser(
          "console", help="launch an interactive python shell"
      )
      console_parser.set_defaults(func=console)
  
      exec_parser = commands.add_parser(
          "exec",
          help="run a shell command in this project's virtual env",
      )
      exec_parser.set_defaults(func=execute)
  
      install_parser = commands.add_parser(
          "install", help="install dependencies in a virtualenv"
      )
      install_parser.set_defaults(func=install)
      install_parser.add_argument(
          "--native",
          help="build optimized native dependencies (tensorflow)",
          action="store_true",
      )
      install_parser.add_argument(
          "--upgrade",
          help="recalculate requirements.frozen.txt with current versions",
          action="store_true",
      )
  
      generate_parser = commands.add_parser(
          "generate", help="create a new model"
      )
      generators = generate_parser.add_subparsers()
      scaffold_parser = generators.add_parser(
          "scaffold",
      )
      scaffold_parser.set_defaults(func=generate_scaffold)
      scaffold_parser.add_argument(
          "name", metavar="NAME", help="name of the project"
      )
      scaffold_parser.add_argument(
          "--keras", help="create a keras scaffold", action="store_true"
      )
      scaffold_parser.add_argument(
          "--xgboost",
          help="create a xgboost scaffold",
          action="store_true",
      )
      scaffold_parser.add_argument(
          "--sklearn",
          help="create a sklearn scaffold",
          action="store_true",
      )
      scaffold_parser.add_argument(
          "--holdout",
          help="create a holdout pipeline",
          action="store_true",
      )
      scaffold_parser.add_argument(
          "--regression",
          help="inherit from lore.estimators.keras.Regression",
          action="store_true",
      )
      scaffold_parser.add_argument(
          "--binary_classifier",
          help="inherit from lore.estimators.keras.BinaryClassifier",
          action="store_true",
      )
      scaffold_parser.add_argument(
          "--multi_classifier",
          help="inherit from lore.estimators.keras.MultiClassifier",
          action="store_true",
      )
  
      model_parser = generators.add_parser("model")
      model_parser.set_defaults(func=generate_model)
      model_parser.add_argument(
          "name", metavar="NAME", help="name of the model"
      )
      model_parser.add_argument(
          "--keras",
          help="inherit from lore.models.keras.Base",
          action="store_true",
      )
      model_parser.add_argument(
          "--xgboost",
          help="inherit from lore.models.xgboost.Base",
          action="store_true",
      )
      model_parser.add_argument(
          "--sklearn",
          help="inherit from lore.models.sklearn.Base",
          action="store_true",
      )
  
      estimator_parser = generators.add_parser("estimator")
      estimator_parser.set_defaults(func=generate_estimator)
      estimator_parser.add_argument(
          "name", metavar="NAME", help="name of the estimator"
      )
      estimator_parser.add_argument(
          "--keras",
          help="inherit from lore.estimators.keras.Base",
          action="store_true",
      )
      estimator_parser.add_argument(
          "--xgboost",
          help="create a xgboost scaffold",
          action="store_true",
      )
      estimator_parser.add_argument(
          "--sklearn",
          help="create a sklearn scaffold",
          action="store_true",
      )
      estimator_parser.add_argument(
          "--regression",
          help="inherit from lore.estimators.keras.Regression",
          action="store_true",
      )
      estimator_parser.add_argument(
          "--binary_classifier",
          help="inherit from lore.estimators.keras.BinaryClassifier",
          action="store_true",
      )
      estimator_parser.add_argument(
          "--multi_classifier",
          help="inherit from lore.estimators.keras.MultiClassifier",
          action="store_true",
      )
  
      pipeline_parser = generators.add_parser("pipeline")
      pipeline_parser.set_defaults(func=generate_pipeline)
      pipeline_parser.add_argument(
          "name", metavar="NAME", help="name of the pipeline"
      )
      pipeline_parser.add_argument(
          "--holdout",
          help="inherit from lore.pipelines.holdout.Base",
          action="store_true",
      )
  
      generate_test_parser = generators.add_parser("test")
      generate_test_parser.set_defaults(func=generate_test)
      generate_test_parser.add_argument(
          "name", metavar="NAME", help="name of the model"
      )
      generate_test_parser.add_argument(
          "--keras", help="create a keras test", action="store_true"
      )
      generate_test_parser.add_argument(
          "--xgboost", help="create a xgboost test", action="store_true"
      )
      generate_test_parser.add_argument(
          "--sklearn", help="create a sklearn test", action="store_true"
      )
  
      generate_notebooks_parser = generators.add_parser("notebooks")
      generate_notebooks_parser.set_defaults(func=generate_notebooks)
      generate_notebooks_parser.add_argument(
          "name", metavar="NAME", help="name of the model"
      )
      generate_notebooks_parser.add_argument(
          "--keras", help="create a keras notebook", action="store_true"
      )
      generate_notebooks_parser.add_argument(
          "--xgboost",
          help="create a xgboost notebook",
          action="store_true",
      )
      generate_notebooks_parser.add_argument(
          "--sklearn",
          help="create a sklearn notebook",
          action="store_true",
      )
  
      fit_parser = commands.add_parser("fit", help="train models")
      fit_parser.set_defaults(func=fit)
      fit_parser.add_argument(
          "model",
          metavar="MODEL",
          help="fully qualified model including module name. e.g. app.models.project.Model",
      )
      fit_parser.add_argument(
          "--test",
          help="calculate the loss on the prediction against the test set",
          action="store_true",
      )
      fit_parser.add_argument(
          "--score",
          help="score the model, typically inverse of loss",
          action="store_true",
      )
      fit_parser.add_argument(
          "--upload",
          help="upload model to store after fitting",
          action="store_true",
      )
  
      hyper_fit_parser = commands.add_parser(
          "hyper_fit", help="search model hyper parameters"
      )
      hyper_fit_parser.set_defaults(func=hyper_fit)
      hyper_fit_parser.add_argument(
          "model",
          metavar="MODEL",
          help="fully qualified model including module name. e.g. app.models.project.Model",
      )
      hyper_fit_parser.add_argument(
          "--test",
          help="calculate the loss on the prediction against the test set",
          action="store_true",
      )
      hyper_fit_parser.add_argument(
          "--score",
          help="score the model, typically inverse of loss",
          action="store_true",
      )
      hyper_fit_parser.add_argument(
          "--upload",
          help="upload model to store after fitting",
          action="store_true",
      )
  
      server_parser = commands.add_parser(
          "server",
          help="launch the flask server to provide an api to your models",
      )
      server_parser.set_defaults(func=server)
      server_parser.add_argument(
          "--host",
          help="listen on host",
      )
      server_parser.add_argument("-p", "--port", help="listen on port")
  
      pip_parser = commands.add_parser(
          "pip", help="pass a command to this project's virtual env pip"
      )
      pip_parser.set_defaults(func=pip)
  
      python_parser = commands.add_parser(
          "python",
          help="pass a command to this project's virtual env python",
      )
      python_parser.set_defaults(func=python)
  
      notebook_parser = commands.add_parser(
          "notebook",
          help="pass a command to this project's virtual env jupyter notebook",
      )
      notebook_parser.set_defaults(func=notebook)
  
      lab_parser = commands.add_parser(
          "lab", help="launch jupyter labs, with access to all envs"
      )
      lab_parser.set_defaults(func=lab)
  
      task_parser = commands.add_parser(
          "task", help="execute a task in the lore environment"
      )
      task_parser.set_defaults(func=task)
      task_parser.add_argument(
          "task",
          metavar="TASK",
          help="fully qualified task name. e.g. app.tasks.project.Task",
          nargs="*",
      )
  
      test_parser = commands.add_parser("test", help="run tests")
      test_parser.add_argument(
          "modules",
          nargs="?",
          help="test only certain modules, e.g. tests.unit.test_foo,tests.unit.test_bar",
      )
      test_parser.set_defaults(func=test)
  
      (known, unknown) = parser.parse_known_args(args)
      if "--env-launched" in unknown:
          unknown.remove("--env-launched")
      if "--env-checked" in unknown:
          unknown.remove("--env-checked")
      if hasattr(known, "func"):
          known.func(known, unknown)
      else:
          parser.print_help(sys.stderr)
  
imports: from __future__ import absolute_import, unicode_literals
  import argparse
  import datetime
  import distutils.dir_util
  import glob
  from io import open
  import importlib
  import inspect
  import json
  import logging
  import os
  import platform
  import pkgutil
  import re
  import shutil
  import subprocess
  import sys
  import lore
  from lore import ansi, env, util
  from lore.util import timer, which
label_desc: Use image node_id 1 for calling a global function with example usage: main(args) without return types