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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
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

Parameters:

Name Type Description Default
args [str]

command line parameters as list of strings

required

Returns:

Type Description

obj:argparse.Namespace: command line parameters namespace

Source code in scripts/cctbx/cctbx_start.py
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
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
220
221
222
def run():
    """Entry point for console_scripts"""
    main(sys.argv[1:])