Skip to content

Tasks Table

tasks/tasks.py

TasksDB

TasksDB(dburi='localhost/tm_admin')

Bases: DBSupport

Parameters:

Name Type Description Default
dburi str

The URI string for the database connection.

'localhost/tm_admin'

Returns:

Type Description
TasksDB

An instance of this class.

Source code in tm_admin/tasks/tasks.py
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(self,
            dburi: str = "localhost/tm_admin",
            ):
    """
    A class to access the tasks table.

    Args:
        dburi (str): The URI string for the database connection.

    Returns:
        (TasksDB): An instance of this class.
    """
    self.profile = TasksTable()
    super().__init__('tasks')

mergeAnnotations async

mergeAnnotations(inpg)

Merge the task_annotation table from Tasking Manager into TM Admin. This table doesn't actually appear to be currently used by TM at all.

Source code in tm_admin/tasks/tasks.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
async def mergeAnnotations(self,
                    inpg: PostgresClient,
                    ):
    """
    Merge the task_annotation table from Tasking Manager into
    TM Admin. This table doesn't actually appear to be currently
    used by TM at all.
    """
    table = "task_annotations"
    log.error(f"mergeAnnotations() Unimplemented as the source is empty!")
    timer = Timer(initial_text="Merging {table} table...",
                  text="merging {table table took {seconds:.0f}s",
                  logger=log.debug,
                )
    log.info(f"Merging {table} table...")

mergeAuxTables async

mergeAuxTables(inuri, outuri)

Merge more tables from TM into the unified tasks table.

Parameters:

Name Type Description Default
inuri str

The input database

required
outuri str

The output database

required
Source code in tm_admin/tasks/tasks.py
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
async def mergeAuxTables(self,
                         inuri: str,
                         outuri: str,
                         ):
    """
    Merge more tables from TM into the unified tasks table.

    Args:
        inuri (str): The input database
        outuri (str): The output database
    """
    await self.connect(outuri)

    inpg = PostgresClient()
    await inpg.connect(inuri)

    # FIXME: in TM, this table is empty
    # await self.mergeAnnotations(inpg)

    await self.mergeHistory(inpg)

    await self.mergeInvalidations(inpg)

mergeHistory async

mergeHistory(inpg)

A method to merge the contents of the TM campaign_projects into the campaigns table as an array.

Source code in tm_admin/tasks/tasks.py
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
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
218
219
220
221
222
223
224
225
    async def mergeHistory(self,
                        inpg: PostgresClient,
                        ):
        """
        A method to merge the contents of the TM campaign_projects into
        the campaigns table as an array.
        """
        table = 'task_history'
        timer = Timer(initial_text=f"Merging {table} table...",
                        text="merging table took {seconds:.0f}s",
                        logger=log.debug,
                    )
        log.info(f"Merging {table} table...")
        timer.start()

        # There is a small amount of data in this table, and we need to
        # coorelate it to the task history when merging, so read in
        # the entire dataset.
        sql = f"SELECT * FROM task_mapping_issues ORDER BY id;"
        # print(sql)
        data = await inpg.execute(sql)
        entries = len(data)
        log.debug(f"There are {len(data)} records in task_mapping_issues")
        issues = dict()
        # pbar = tqdm.tqdm(data)
        # for record in pbar:
        for record in data:
            hid = record['task_history_id']
            issues[hid] = {'issue': record['issue'],
                           'category': record['mapping_issue_category_id'],
                           'count': record['count'],
                           }

        # Now get the data from the history table
        sql = f"SELECT * FROM {table}"
        # print(sql)
        data = await inpg.execute(sql)
        entries = len(data)
        log.debug(f"There are {len(data)} records in {table}")

        chunk = round(entries/cores)

        # FIXME: create an array of SQL queries, so later we can use
        # prepared_queries in asyncpg for better performance. We also don't
        # need all of the columns from the TM table, since task ID and
        # project ID are already part of the table schema.
        queries = list()
        # pbar = tqdm.tqdm(data)
        #for record in pbar:
        for record in data:
            entry = {"user_id": record['user_id']}
            # entry['action'] = Taskaction(record['action']).name
            entry['action'] = record['action']
            # The action_text column often has issues with embedded
            # quotes.
            if record['action_text']:
                fix = record['action_text'].replace('"', '"')
            entry['action_text'] = fix.replace("'", ''').replace("\xa0", "")
            if record['action_date']:
                entry['action_date'] = '{:%Y-%m-%dT%H:%M:%S}'.format(record['action_date'])
            # If there is an issue, add it to the record in the jsonb column
            if record['id'] in issues:
                entry.update(issues[record['id']])
                entry.update(issues[record['id']])
                # entry['issue'] = issues['issue']
                # entry['category'] = issues['category']
                # entry['count'] = issues['count']
            asc = str(entry).replace("'", '"').replace("\\'", "'")
            sql = "UPDATE tasks SET history = '{\"history\": [%s]}' WHERE id=%d AND project_id=%d" % (asc, record['task_id'], record['project_id'])
            # print(sql)
            queries.append(sql)

            # Add a timestamp to the created column so this table can
            # be partitioned.
            sql = f"UPDATE tasks SET created = '{entry['action_date']}' WHERE id={record['task_id']} AND project_id={record['project_id']}"
            # print(sql)
            queries.append(sql)

        entries = len(queries)
        chunk = round(entries/cores)
        import copy
        async with asyncio.TaskGroup() as tg:
            for block in range(0, entries, chunk):
                # for index in range(0, cores):
                outpg = PostgresClient()
                # FIXME: this should not be hard coded
                await outpg.connect('localhost/tm_admin')
                # FIXME: this may be removed after testing, but memory
                # corruption errors fored this workaround.
                foo = copy.copy(queries[block:block + chunk -1])
                log.debug(f"Dispatching thread {block}:{block + chunk - 1}")
#                await updateThread(foo, outpg)
                # await updateThread(queries[block:block + chunk], outpg)
                task = tg.create_task(updateThread(foo, outpg))
        timer.stop()

mergeInvalidations async

mergeInvalidations(inpg)

A method to merge the contents of the TM campaign_projects into the campaigns table as an array.

Source code in tm_admin/tasks/tasks.py
227
228
229
230
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
256
257
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
async def mergeInvalidations(self,
                    inpg: PostgresClient,
                    ):
    """
    A method to merge the contents of the TM campaign_projects into
    the campaigns table as an array.
    """
    table = 'task_invalidation_history'
    timer = Timer(initial_text=f"Merging {table} table...",
                    text="merging table took {seconds:.0f}s",
                    logger=log.debug,
                )
    log.info(f"Merging {table} table...")

    sql = f"SELECT * FROM {table} ORDER BY project_id"
    # print(sql)
    timer.start()
    data = await inpg.execute(sql)
    entries = len(data)
    log.debug(f"There are {entries} records in {table}")

    # FIXME: create an array of SQL queries, so later we can use
    # prepared_queries in asyncpg for better performance.
    queries = list()
    for record in data:
        tid = record['task_id']
        entry = {"mapper_id": record['mapper_id']}
        if record['invalidator_id']:
            entry['invalidator_id'] = record['invalidator_id']
        else:
            entry['invalidator_id'] = 0
        if record['validator_id']:
            entry['validator_id'] = record['validator_id']
        else:
            entry['validator_id'] = 0
        if record['mapped_date']:
            entry['mapped_date'] = '{:%Y-%m-%dT%H:%M:%S}'.format(record['mapped_date'])
        if record['invalidated_date']:
            entry['mapped_date'] = '{:%Y-%m-%dT%H:%M:%S}'.format(record['invalidated_date'])
        if record['validated_date']:
            entry['mapped_date'] = '{:%Y-%m-%dT%H:%M:%S}'.format(record['validated_date'])
        if record['updated_date']:
            entry['mapped_date'] = '{:%Y-%m-%dT%H:%M:%S}'.format(record['updated_date'])
        if record['is_closed']:
            entry["is_closed_id"] = "true"
        else:
            entry["is_closed_id"] = "false"
        # entries[record['task_id']].append(entry)
        asc = str(entry).replace("'", '"').replace("\\'", "'")
        sql = "UPDATE tasks SET history = '{\"history\": [%s]}' WHERE id=%d AND project_id=%d" % (asc, record['task_id'], record['project_id'])
        # print(sql)
        queries.append(sql)

    entries = len(queries)
    chunk = round(entries / cores)
    async with asyncio.TaskGroup() as tg:
        for block in range(0, entries, chunk):
            # for index in range(0, cores):
            outpg = PostgresClient()
            # FIXME: this should not be hard coded
            await outpg.connect('localhost/tm_admin')
            log.debug(f"Dispatching thread {block}:{block + chunk}")
            #await updateThread(queries[block:block + chunk], outpg)
            task = tg.create_task(updateThread(queries[block:block + chunk], outpg))

updateThread async

updateThread(queries, db)

Thread to handle importing data

Parameters:

Name Type Description Default
queries list

The list of SQL queries to execute

required
db PostgresClient

A database connection

required
Source code in tm_admin/tasks/tasks.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
async def updateThread(
    queries: list,
    db: PostgresClient,
):
    """Thread to handle importing data

    Args:
        queries (list): The list of SQL queries to execute
        db (PostgresClient): A database connection
    """
    pbar = tqdm.tqdm(queries)
    for sql in pbar:
    # for sql in queries:
        # print(sql)
        result = await db.execute(sql)

    return True

main async

main()

This main function lets this class be run standalone by a bash script.

Source code in tm_admin/tasks/tasks.py
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
async def main():
    """This main function lets this class be run standalone by a bash script."""
    parser = argparse.ArgumentParser()
    parser.add_argument("-v", "--verbose", nargs="?", const="0", help="verbose output")
    parser.add_argument("-i", "--inuri", default='localhost/tm4',
                            help="Database URI")
    parser.add_argument("-o", "--outuri", default='localhost/tm_admin',
                            help="Database URI")
    # parser.add_argument("-r", "--reset", help="Reset Sequences")
    args = parser.parse_args()

    # if len(argv) <= 1:
    #     parser.print_help()
    #     quit()

    # if verbose, dump to the terminal.
    log_level = os.getenv("LOG_LEVEL", default="INFO")
    if args.verbose is not None:
        log_level = logging.DEBUG

    logging.basicConfig(
        level=log_level,
        format=("%(asctime)s.%(msecs)03d [%(levelname)s] " "%(name)s | %(funcName)s:%(lineno)d | %(message)s"),
        datefmt="%y-%m-%d %H:%M:%S",
        stream=sys.stdout,
    )

    tasks = TasksDB(args.inuri)
    await tasks.mergeAuxTables(args.inuri, args.outuri)

options: show_source: false heading_level: 3

tasks/tasks_class.py

options: show_source: false heading_level: 3

tasks/api.py

TasksAPI

TasksAPI()

Bases: PGSupport

Returns:

Type Description
TasksAPI

An instance of this class

Source code in tm_admin/tasks/api.py
62
63
64
65
66
67
68
69
70
71
72
def __init__(self):
    """
    Create a class to handle the backend API calls, so the code can be shared
    between test cases and the actual code.

    Returns:
        (TasksAPI): An instance of this class
    """
    super().__init__("tasks")
    self.projects =  tm_admin.projects.api.ProjectsAPI()
    self.users = tm_admin.users.api.UsersAPI()

initialize async

initialize(inuri)

Connect to all tables for API endpoints that require accessing multiple tables.

Parameters:

Name Type Description Default
inuri str

The URI for the TM Admin output database

required
Source code in tm_admin/tasks/api.py
74
75
76
77
78
79
80
81
82
83
84
85
86
87
async def initialize(self,
                  inuri: str,
                  ) -> None:
    """
    Connect to all tables for API endpoints that require
    accessing multiple tables.

    Args:
        inuri (str): The URI for the TM Admin output database
    """
    await self.connect(inuri)
    await self.getTypes("tasks")
    self.projects = tm_admin.projects.api.ProjectsAPI()
    self.users = tm_admin.users.api.UsersAPI()

getStatus async

getStatus(task_id, project_id)

Get the current status for a task using it's project and task IDs.

Parameters:

Name Type Description Default
task_id int

The task to lock

required
project_id int

The team to get the data for

required

Returns:

Type Description
dict

the project information

Source code in tm_admin/tasks/api.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
async def getStatus(self,
                  task_id: int,
                  project_id: int,
                ) -> Taskstatus:
    """
    Get the current status for a task using it's project and task IDs.

    Args:
        task_id (int): The task to lock
        project_id (int): The team to get the data for

    Returns:
        (dict): the project information
    """
    log.debug(f"--- getByID() ---")
    sql = f"SELECT task_status FROM tasks WHERE project_id={project_id} AND id={task_id}"
    results = await self.execute(sql)
    return results

getByID async

getByID(task_id, project_id)

Get all the information for a task using it's project and task IDs.

Parameters:

Name Type Description Default
task_id int

The task to lock

required
project_id int

The team to get the data for

required

Returns:

Type Description
dict

the project information

Source code in tm_admin/tasks/api.py
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
async def getByID(self,
                  task_id: int,
                  project_id: int,
                ):
    """
    Get all the information for a task using it's project and task IDs.

    Args:
        task_id (int): The task to lock
        project_id (int): The team to get the data for

    Returns:
        (dict): the project information
    """
    log.debug(f"--- getByID() ---")
    sql = f"SELECT * FROM tasks WHERE project_id={project_id} AND id={task_id}"
    results = await self.execute(sql)
    return results

getByUser async

getByUser(user_id, task_id, project_id)

Get all the information for a project using it's ID

Parameters:

Name Type Description Default
user_id int

The user ID to lock

required
task_id int

The task to lock

required
project_id int

The project this task is part of

required

Returns:

Type Description
dict

the task information

Source code in tm_admin/tasks/api.py
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
async def getByUser(self,
                    user_id: int,
                    task_id: int,
                    project_id: int,
                    ):
    """
    Get all the information for a project using it's ID

    Args:
        user_id (int): The user ID to lock
        task_id (int): The task to lock
        project_id (int): The project this task is part of

    Returns:
        (dict): the task information
    """
    log.debug(f"--- getByID() ---")
    sql = f"SELECT * FROM tasks WHERE project_id={project_id} AND id={task_id} AND user_id={user_id}"
    results = await self.execute(sql)
    return results

changeAction async

changeAction(user_id, task_id, project_id, action)

Manage the status of a task. This would be locking or unlocking, validation status, etc...

Parameters:

Name Type Description Default
user_id int

The mapper locking the task

required
task_id int

The task to lock

required
project_id int

The project containing the task

required
action Taskaction

The action to change to

required

Returns:

Type Description
bool

Whether the change was sucessful

Source code in tm_admin/tasks/api.py
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
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
async def changeAction(self,
                    user_id: int,
                    task_id: int,
                    project_id: int,
                    action: Taskaction,
                    ):
    """
    Manage the status of a task. This would be locking or unlocking,
    validation status, etc...

    Args:
        user_id (int): The mapper locking the task
        task_id (int): The task to lock
        project_id (int): The project containing the task
        action (Taskaction): The action to change to

    Returns:
        (bool): Whether the change was sucessful
    """
    # log.warning(f"changeStatus(): unimplemented!")

    # FIXME: Make sure the user is in the allowed_user in the projects table
    # the history
    history = None
    status = None
    now = datetime.now()
    # All actions get written to the history
    history = {"action": action,
               "action_text": action.name,
               "action_date": '{:%Y-%m-%dT%H:%M:%S}'.format(now),
               "user_id": user_id}
    # Actions change the status
    if action == Taskaction.LOCKED_FOR_MAPPING:
        status = Taskstatus(Taskstatus.TASK_LOCKED_FOR_MAPPING)
    elif action == Taskaction.LOCKED_FOR_VALIDATION:
        status = Taskstatus(Taskstatus.TASK_LOCKED_FOR_VALIDATIONG)
    elif action == Taskaction.STATE_CHANGE:
        pass
    elif action == Taskaction.COMMENT:
        pass
    elif action == Taskaction.AUTO_UNLOCKED_FOR_MAPPING:
        status = Taskstatus(Taskstatus.READY)
    elif action == Taskaction.AUTO_UNLOCKED_FOR_VALIDATION:
        status = Taskstatus(Taskstatus.TASK_LOCKED_FOR_VALIDATION)
    elif action == Taskaction.EXTENDED_FOR_MAPPING:
        status = Taskactipon(Taskaction.READY) # FIXME: Huh ?
    elif action == Taskaction.EXTENDED_FOR_VALIDATION:
        status = Taskaction(Taskaction.READY) # FIXME: Huh ?
    elif action == Taskaction.RELEASED_FOR_MAPPING:
        status = Taskstatus(Taskaction.READY) # FIXME: Huh ?
    elif action == Taskaction.MARKED_MAPPED:
        status = Taskstatus(Taskaction.TASK_STATUS_MAPPED)
    elif action == Taskaction.VALIDATED:
        status = Taskstatus(Taskaction.VALIDATED)
    elif action == Taskaction.TASK_MARKED_INVALID:
        status = Taskstatus(Taskaction.TASK_INVALIDATED)
    elif action == Taskaction.MARKED_BAD:
        # FIXME: this should set the mapping issue
        status = Taskstatus(Taskaction.READY) # FIXME: Huh ?
    elif action == Taskaction.SPLIT_NEEDED:
        status = Taskstatus(Taskaction.SPLIT)
    elif action == Taskaction.RECREATED:
        status = Taskstatus(Taskaction.READY) # FIXME: Huh ?

    # FIXME: For some reason if I try to pass the dict inline,
    # it gets converted to a set, so then fails.
    stats = {"task_status": status}
    await self.updateColumns(stats,
                             {"task_id": task_id,
                              "project_id": project_id})

lockTask async

lockTask(task_id, project_id, user_id)

Lock a task to a mapper

Parameters:

Name Type Description Default
user_id int

The user ID to lock

required
task_id int

The task to update

required
project_id int

The project this task is in

required

Returns:

Type Description
Mappingnotallowed

If locking was sucessful or not

Source code in tm_admin/tasks/api.py
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
async def lockTask(self,
                   task_id: int,
                   project_id: int,
                   user_id: int,
                   ):
    """
    Lock a task to a mapper

    Args:
        user_id (int): The user ID to lock
        task_id (int): The task to update
        project_id (int): The project this task is in

    Returns:
        (Mappingnotallowed): If locking was sucessful or not
    """

    # FIXME: First see if a task is in a valid state to map.
    # Errors from Mappingnotallowed

    result = await projects.permittdUser(user_id, project_id)

    if result == Mappingnotallowed.USER_ALLOWED:
        result = await tasks.changeAction(user_id, task_id, project_id,
                                          Taskaction.LOCKED_FOR_MAPPING)
    else:
        return result

updateHistory async

updateHistory(history, task_id, project_id)

Update the task history column.

Parameters:

Name Type Description Default
history list

The task history to update

required
task_id int

The task to update

required
project_id int

The project this task is in

required

Returns:

Type Description
bool

If it worked

Source code in tm_admin/tasks/api.py
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
async def updateHistory(self,
                        history: list,
                        task_id: int,
                        project_id: int,
                        ):
    """
    Update the task history column.

    Args:
        history (list): The task history to update
        task_id (int): The task to update
        project_id (int): The project this task is in

    Returns:
        (bool): If it worked
    """
    # log.warning(f"updateHistory(): unimplemented!")

    data = str()
    for entry in history:
        for k, v in entry.items():
            if str(type(v))[:5] == "<enum":
                data += f'" {v.name}", '
            else:
                data += f'" {v}", '
            #asc = str(entry).replace("'", '"').replace("\\'", "'")
        sql = "UPDATE tasks SET history = '{\"history\": [%s]}' WHERE id=%d AND project_id=%d" % (data[:-2], task_id, project_id)
        print(sql)
        result = await self.execute(sql)

appendHistory async

appendHistory(history, task_id, project_id)

Update the task history column.

Parameters:

Name Type Description Default
history list

The task history to update

required
task_id int

The task to update

required
project_id int

The project this task is in

required

Returns:

Type Description
bool

If it worked

Source code in tm_admin/tasks/api.py
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
async def appendHistory(self,
                        history: list,
                        task_id: int,
                        project_id: int,
                        ):
    """
    Update the task history column.

    Args:
        history (list): The task history to update
        task_id (int): The task to update
        project_id (int): The project this task is in

    Returns:
        (bool): If it worked
    """
    # log.warning(f"updateHistory(): unimplemented!")

    data = dict()
    data['history'] = list()
    for entry in history:
        # SQL wants the string value
        if "action" in entry:
            entry['action'] = entry['action'].name
        if "is_closed" in entry:
            entry['is_closed'] = str(entry['is_closed']).lower()
        asc = str(entry).replace("'", '"').replace("\\'", "'")
        sql = "UPDATE tasks SET history = history||'[%s]'::jsonb WHERE id=%d AND project_id=%d" % (asc, task_id, project_id)
        # print(sql)
        result = await self.execute(sql)

        # Update the task status
        if "action" in entry:
            status = None
            if entry['action'] == Taskaction.VALIDATED:
                status = Taskstatus.TASK_VALIDATED
            elif entry['action'] == Taskaction.MARKED_INVALID:
                status = Taskstatus.TASK_INVALIDATED
            elif entry['action'] == Taskaction.MARKED_INVALID:
                status = Taskstatus.TASK_VALIDATED
            if status:
                result = await self.updateColumns({"status": status},
                                                  {"id": task_id,
                                                  "project_id": project_id})

updateIssues async

updateIssues(issues, task_id, project_id)

Update the task history column.

Parameters:

Name Type Description Default
issues list

The issues for this task

required
task_id int

The task to update

required
project_id int

The project this task is in

required

Returns:

Type Description
bool

If it worked

Source code in tm_admin/tasks/api.py
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
async def updateIssues(self,
                        issues: list,
                        task_id: int,
                        project_id: int,
                        ):
    """
    Update the task history column.

    Args:
        issues (list): The issues for this task
        task_id (int): The task to update
        project_id (int): The project this task is in

    Returns:
        (bool): If it worked
    """
    # log.warning(f"updateHistory(): unimplemented!")

    data = str()
    for entry in issues:
        for k, v in entry.items():
            if str(type(v))[:5] == "<enum":
                data += f'" {v.name}", '
            else:
                data += f'" {v}", '
            #asc = str(entry).replace("'", '"').replace("\\'", "'")
        sql = "UPDATE tasks SET issues = '{\"issues\": [%s]}' WHERE id=%d AND project_id=%d" % (data[:-2], task_id, project_id)
        # print(sql)
        result = await self.execute(sql)

markAllMapped async

markAllMapped()

Args:

Returns:

Source code in tm_admin/tasks/api.py
352
353
354
355
356
357
358
359
360
361
362
async def markAllMapped(self):
    """

    Args:

    Returns:

    """
    log.warning(f"markAllMapped(): unimplemented!")

    return False

resetBadImagery async

resetBadImagery()

Args:

Returns:

Source code in tm_admin/tasks/api.py
364
365
366
367
368
369
370
371
372
373
374
async def resetBadImagery(self):
    """

    Args:

    Returns:

    """
    log.warning(f"resetBadImagery(): unimplemented!")

    return False

undoMapping async

undoMapping()

Args:

Returns:

Source code in tm_admin/tasks/api.py
376
377
378
379
380
381
382
383
384
385
386
async def undoMapping(self):
    """

    Args:

    Returns:

    """
    log.warning(f"undoMapping(): unimplemented!")

    return False

main async

main()

This main function lets this class be run standalone by a bash script.

Source code in tm_admin/tasks/api.py
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
async def main():
    """This main function lets this class be run standalone by a bash script."""
    parser = argparse.ArgumentParser()
    parser.add_argument("-v", "--verbose", nargs="?", const="0", help="verbose output")
    parser.add_argument("-u", "--uri", default='localhost/tm_admin', help="Database URI")

    args = parser.parse_args()

    # if verbose, dump to the terminal.
    log_level = os.getenv("LOG_LEVEL", default="INFO")
    if args.verbose is not None:
        log_level = logging.DEBUG

    logging.basicConfig(
        level=log_level,
        format=("%(asctime)s.%(msecs)03d [%(levelname)s] " "%(name)s | %(funcName)s:%(lineno)d | %(message)s"),
        datefmt="%y-%m-%d %H:%M:%S",
        stream=sys.stdout,
    )

options: show_source: false heading_level: 3


Last update: March 6, 2024