...
Key | Description | Allowed values | Example in the UI |
---|
name | How you refer to the argument within the python script, using self.args.<name> This is also how the arguments are referred to from the load script. Note: In load script, underscores are replaced by hyphens. |
| |
flags | The short command line flag for this argument. See example: Code Block |
---|
language | py |
---|
title | getArguments with flags |
---|
collapse | true |
---|
| def getArguments(self):
return [
{
"name": "very_long_argument_name",
"flags": "n"
}
]
|
Code Block |
---|
language | powershell |
---|
title | Data load command |
---|
collapse | true |
---|
| squirro_data_load \
--<some_default_arguments> \
--n 'hello' |
|
|
|
help | The help string. If display_label is not provided, help takes its place as a main label. Otherwise, it serves as a secondary help text in UI.
Example of code and UI representation is shown under the 'required' argument.
|
|
|
display_label | The short label for this argument shown in the UI. Set explicitly to 'None' to hide this argument from the UI → that will make it only a CLI argument.
Example of code and UI representation is shown under the 'required' argument. |
|
|
required | True if this argument is mandatory. You won't be able to proceed with creation of the load job in the UI if this is not provided. In the CLI mode, an error will be thrown.
Code Block |
---|
language | py |
---|
title | getArguments method demonstrating 'action' |
---|
collapse | true |
---|
| def getArguments(self):
"""
Get arguments required by the plugin
"""
return [
{
"name": "my_required_argument",
"display_label": "Required argument",
"required": True,
"help": "This is an example of a required argument"
}
]
|
| True, False (default) | |
type | Type to try to convert the value of the argument into. Basic types are: str, int, float, bool Special: password - which will be used as a string in the load script, but will be interpreted as a password field in the UI (hidden characters)file - allows passing in files. You then read them as: open(self.args.<file_argument>) in the load script. In UI you will see a file dropdown/selector to allow choosing one from your filesystem.code - e.g. SQL statements. A code-editor-like box will show when creating the loader from UI.
The special types eventually end up as type str for use in the Python script. In UI mode however, they have custom appearance as shown in the examples on the right. | str, int, float, bool, password, file | |
default | The default value of the option |
|
|
action | Action to perform when this flag is given. store is the default and simply allows the usage of the value of the argument within the script
store_true will turn the value of the argument to True if provided, False if not provided. Turned into a checkbox in the UI.
store_false will turn the value of the argument to False if provided, True otherwise. Turned into a checkbox in the UI.
See below examples for clarity Code Block |
---|
language | py |
---|
title | getArguments method demonstrating 'action' |
---|
collapse | true |
---|
| def getArguments(self):
return [
{
"name": "my_flag_1",
"action": "store"
},
{
"name": "my_flag_2",
"action": "store_true"
},
{
"name": "my_flag_3",
"action": "store_true"
}
]
|
Code Block |
---|
language | powershell |
---|
title | Data load command |
---|
collapse | true |
---|
| squirro_data_load \
--<some_default_arguments> \
--my_flag_1 'any_string' \
--my_flag_2 |
Code Block |
---|
language | py |
---|
title | store usage |
---|
collapse | true |
---|
| def somewhere_within_the_custom_loader(self):
log.info(self.args.my_flag_1)
// prints 'any_string'
log.info(self.args.my_flag_2)
//prints True
log.info(self.args.my_flag_3)
//prints False, since my_flag_3 was not provided in the load script
|
| store (default), store_true, store_false | |
nargs | Can be set to "*" if multiple values can be provided for this value."+" can be used if more than one value must be provided. This is used if you want the user to provide a list of arguments, such as list of IDs, URLs etc. The resulting value is made available as a list in the source code. E.g. Code Block |
---|
language | py |
---|
title | getArguments with 'nargs' |
---|
collapse | true |
---|
| def getArguments(self):
return [
{
"name": "multi_value_arg",
"nargs": "*"
}
]
|
Code Block |
---|
language | powershell |
---|
title | Data load command |
---|
collapse | true |
---|
| squirro_data_load \
--<some_default_arguments> \
--multi_value_arg 'url_1' 'url_2' 'url_3'
|
| *, + | |
advanced | The UI setting is hidden behind an "Advanced Options" area. | True, False (default) | Image Added |
getDataBatch
(required)
This method is at the core of data loading. It will return the records from the data source as a dictionary structure. These records are usually referred to as "rows" in the context of the data loader. The data loader will then use this structure and convert it into Squirro items (see Item Format) using the user-provided mapping configuration.
...