/
rm.py
41 lines (35 loc) · 1.22 KB
/
rm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.
"""
Remove jobs from pyiron project or whole project.
"""
import os
from pyiron_base.project.generic import Project
__author__ = "Marvin Poul"
__copyright__ = (
"Copyright 2020, Max-Planck-Institut für Eisenforschung GmbH - "
"Computational Materials Design (CM) Department"
)
__version__ = "1.0"
__maintainer__ = "Marvin Poul"
__email__ = "poul@mpie.de"
__status__ = "production"
__date__ = "23 Jun, 2020"
def register(parser):
parser.add_argument(
"project", default=".", nargs="?", help="path to pyiron project"
)
parser.add_argument(
"-j", "--jobs-only", action="store_true", help="only remove jobs inside project"
)
parser.add_argument(
"-r", "--recursive", action="store_true", help="recurse into subprojects"
)
def main(args):
pr = Project(args.project)
if args.jobs_only:
pr.remove_jobs(recursive=args.recursive, silently=True)
else:
pr.remove(enable=True)
if os.path.exists(args.project) and not os.listdir(args.project):
os.rmdir(args.project)