tasklets
Tasklet functions to be run before or after a Task.
"Tasklets" are simple processing steps which are intended to be run by an
Executor after the main Task has finished. These functions help provide a way to
handle some common operations which may need to be performed, such as examining
an output text file, or doing simple file conversions. These operations can be
also be imported for use in first-party Tasks. In particular for
ThirdPartyTasks, it is not easy to append operations to a Task which is why
the Executor mechanism is provided.
Functions:
| Name | Description |
|---|---|
git_clone |
str, location: str, permissions: str): Clone a git repo. |
clone_smalldata |
str): Clone smalldata_tools based on the location of the producer file. |
concat_files |
str, in_files_glob: str, out_file: str): Concatenate a group of files into a single output file. |
grep |
str, in_file: str) -> str | List[str]: grep for text in a specific file. Returns the results. |
indexamajig_summary_indexing_rate |
str) -> Dict[str, str]: Parse an output stream file to determine indexed patterns/indexing rate. |
compare_hkl_fom_summary |
str, figure_display_name: str) -> Tuple[Dict[str, str], Optional[ElogSummaryPlots]]: Extract the figure of merit and produce a plot of figure of merit/resolution ring. |
setup_dimple_uglymol |
str, experiment: str, density_display_name: str ) -> None: Set's up the javascript and HTML files needed to display electron density in the eLog using UglyMol and the output from dimple. |
Usage
As tasklets are just functions they can be imported and used within Task code normally if needed.
However, tasklets can also be managed through the Executor in a similar way to environment changes. E.g., to add a tasklet to an Executor instance one would:
First create Executor instance as normal to run the Task
MyTaskRunner: Executor = Executor("RunMyTask")
MyTaskRunner.update_environment(...) # if needed
MyTaskRunner.add_tasklet( tasklet, args, when="before", set_result=False, set_summary=False )
A special substitution syntax can be used in args if specific values
from a TaskParameters object will be needed to run the Tasklet:
args=("{{ param_to_sub }}", ...)
clone_smalldata(producer_location, patch=None)
Clone smalldata_tools based on producer location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
producer_location
|
str
|
Full path to the producer to be used. |
required |
patch
|
Optional[str]
|
The path to a patch to apply (if desired). |
None
|
Source code in lute/tasks/tasklets.py
175 176 177 178 179 180 181 182 183 184 185 186 187 | |
compare_hkl_fom_summary(shell_file, figure_display_name)
Analyze information produced by CrystFEL's compare_hkl.
Extracts figures of merit information and produces text summary and plots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shell_file
|
str
|
Path to output |
required |
figure_display_name
|
str
|
Display name of the figure in the eLog. |
required |
Source code in lute/tasks/tasklets.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
concat_files(location, in_files_glob, out_file)
Concatenate a series of files into a single output file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
str
|
Path to the files to concatenate. |
required |
in_files_glob
|
str
|
A glob to match a series of files at the specified path. These will all be concatenated. |
required |
out_file
|
str
|
Name of the concatenated output. |
required |
Source code in lute/tasks/tasklets.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
git_clone(repo, location, permissions, patch=None)
Clone a git repository.
Will not overwrite a directory of there is already a folder at the specified location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo
|
str
|
Name of the repository to clone. Should be specified as:
" |
required |
location
|
str
|
Path to the location to clone to. |
required |
permissions
|
str
|
Permissions to set on the repository. |
required |
patch
|
Optional[str]
|
The path to a patch to apply (if desired). |
None
|
Source code in lute/tasks/tasklets.py
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 162 163 164 165 166 167 168 169 170 171 172 | |
grep(match_str, in_file)
Grep for specific lines of text output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match_str
|
str
|
String to search for. |
required |
in_file
|
str
|
File to search. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
lines |
List[str]
|
The matches. It may be a list with just an empty string if nothing is found. |
Source code in lute/tasks/tasklets.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
indexamajig_summary_indexing_rate(stream_file)
Return indexing rate from indexamajig output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream_file
|
str
|
Input stream file. |
required |
Source code in lute/tasks/tasklets.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
modify_permissions(path, permissions)
Recursively set permissions for a path.
Source code in lute/tasks/tasklets.py
105 106 107 108 109 110 111 112 113 | |
setup_dimple_uglymol(final_mtz, experiment, density_display_name)
Setup uglymol so electron density can be explored in eLog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
final_mtz
|
str
|
Path to the output MTZ file after running dimple. |
required |
experiment
|
str
|
Experiment name. |
required |
density_display_name
|
str
|
Name of the tabbed navigation to find the electron density in the eLog. |
required |
Source code in lute/tasks/tasklets.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
wget(url, out_dir=None)
Pull down some resource.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL of the resource. |
required |
out_dir
|
Optional[str]
|
Path of a directory to write the resource to. If None, will write to the current working directory, which is likely user scratch if running from the eLog. |
None
|
Source code in lute/tasks/tasklets.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |