Skip to content

Cctbx start

cctbx_start

main(args)

Main entry point allowing external calls Entry point for console_scripts Args: args ([str]): command line parameter list

Source code in scripts/cctbx/cctbx_start.py
def main(args):
    """
    Main entry point allowing external calls
    Entry point for console_scripts
    Args:
      args ([str]): command line parameter list
    """
    args = parse_args(args)
    user = args.username
    exp = args.experiment
    facility = args.facility
    debug = bool(args.debug)
    step = args.step

    if int(step) == 1:

        logging.info("Starting up cctbx")

        if facility == "S3DF":
            proc = [
                f"ssh -YAC psana "
                f"/sdf/group/lcls/ds/tools/mfx/scripts/cctbx/cctbx.sh "
                f"{user} {exp} {facility} 2 {str(debug)}"
            ]
        elif facility == "NERSC":
            proc = [
                f"ssh -i ~/.ssh/cctbx -YAC cctbx@perlmutter-p1.nersc.gov "
                f"/global/common/software/lcls/mfx/scripts/cctbx/cctbx.sh "
                f"{user} {exp} {facility} 2 {str(debug)}"
            ]

        logging.info(proc)
        if debug:
            os.system(proc[0])
        else:
            subprocess.Popen(
                proc, shell=True,
                stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)

    else:

        if facility == "NERSC":
            cctbx_dir = f"/global/homes/c/cctbx/.cctbx.xfel"
        elif facility == "S3DF":
            cctbx_dir = f"/sdf/home/{user[0]}/{user}/.cctbx.xfel"
        else:
            cctbx_dir = None
            logging.warning(f"Facility not found: {facility}")

        if cctbx_dir is not None:
            if not os.path.exists(cctbx_dir):
                os.makedirs(cctbx_dir)

            check_settings(exp, facility, cctbx_dir)

parse_args(args)

Parse command line parameters

Args: args ([str]): command line parameters as list of strings

Returns: :obj:argparse.Namespace: command line parameters namespace

Source code in scripts/cctbx/cctbx_start.py
def parse_args(args):
    """Parse command line parameters

    Args:
      args ([str]): command line parameters as list of strings

    Returns:
      :obj:`argparse.Namespace`: command line parameters namespace
    """
    parser = argparse.ArgumentParser(
        description="startup script for cctbx on iana."
    )
    parser.add_argument(
        "--username",
        "-u",
        dest="username",
        default=None,
        help="Enter -u to specify username",
    )
    parser.add_argument(
        "--experiment",
        "-e",
        dest="experiment",
        default=None,
        help="Enter -e to specify experiment number",
    )
    parser.add_argument(
        "--facility",
        "-f",
        dest="facility",
        default=None,
        help="Enter -f to specify facility",
    )
    parser.add_argument(
        "--debug",
        "-d",
        dest="debug",
        default=str(False),
        help="Enter -d to set debugging mode",
    )
    parser.add_argument(
        "--step",
        "-s",
        dest="step",
        default=None,
        help="Enter -s to setup step",
    )

    return parser.parse_args(args)

run()

Entry point for console_scripts

Source code in scripts/cctbx/cctbx_start.py
def run():
    """Entry point for console_scripts"""
    main(sys.argv[1:])