Bases: BaseCommand
This script creates a template image configuration file for use with image ingestion
Source code in vast_pipeline/management/commands/initingest.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 | class Command(BaseCommand):
"""
This script creates a template image configuration file for use with image ingestion
"""
help = (
'Create a template image ingestion configuration file'
)
def add_arguments(self, parser: ArgumentParser) -> None:
"""
Enables arguments for the command.
Args:
parser (ArgumentParser): The parser object of the command.
Returns:
None
"""
parser.add_argument(
'config_file_name',
nargs=1,
type=str,
help=('Filename to write template ingest configuration to.')
)
def handle(self, *args, **options) -> None:
"""
Handle function of the command.
Args:
*args: Variable length argument list.
**options: Variable length options.
Returns:
None
"""
# configure logging
if options['verbosity'] > 1:
# set root logger to use the DEBUG level
root_logger = logging.getLogger('')
root_logger.setLevel(logging.DEBUG)
# set the traceback on
options['traceback'] = True
template_str = make_config_template(
ImageIngestConfig.TEMPLATE_PATH,
**settings.PIPE_RUN_CONFIG_DEFAULTS
)
fname = options['config_file_name'][0]
# Enforce .yml extension
if not fname.endswith('.yaml') and not fname.endswith('.yml'):
fname = fname + '.yml'
print("Writing template to: ", fname)
with open(fname, 'w') as f:
f.write(template_str+"\n")
|
add_arguments(parser)
Enables arguments for the command.
Parameters:
Name | Type | Description | Default |
parser | ArgumentParser | The parser object of the command. | required |
Returns:
Source code in vast_pipeline/management/commands/initingest.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 | def add_arguments(self, parser: ArgumentParser) -> None:
"""
Enables arguments for the command.
Args:
parser (ArgumentParser): The parser object of the command.
Returns:
None
"""
parser.add_argument(
'config_file_name',
nargs=1,
type=str,
help=('Filename to write template ingest configuration to.')
)
|
handle(*args, **options)
Handle function of the command.
Parameters:
Name | Type | Description | Default |
*args | | Variable length argument list. | () |
**options | | | {} |
Returns:
Source code in vast_pipeline/management/commands/initingest.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 | def handle(self, *args, **options) -> None:
"""
Handle function of the command.
Args:
*args: Variable length argument list.
**options: Variable length options.
Returns:
None
"""
# configure logging
if options['verbosity'] > 1:
# set root logger to use the DEBUG level
root_logger = logging.getLogger('')
root_logger.setLevel(logging.DEBUG)
# set the traceback on
options['traceback'] = True
template_str = make_config_template(
ImageIngestConfig.TEMPLATE_PATH,
**settings.PIPE_RUN_CONFIG_DEFAULTS
)
fname = options['config_file_name'][0]
# Enforce .yml extension
if not fname.endswith('.yaml') and not fname.endswith('.yml'):
fname = fname + '.yml'
print("Writing template to: ", fname)
with open(fname, 'w') as f:
f.write(template_str+"\n")
|