Skip to content

Commit

Permalink
some format adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
LoannPeurey committed Dec 4, 2024
1 parent c0d492e commit 4f5a95b
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions ChildProject/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def validate(args):
annotations = am.annotations

if all(map(lambda x: os.path.exists(x) or os.path.islink(x), args.annotations)):
args.annotations = {am.set_from_path(set) for set in args.annotations} - {
args.annotations = {am.set_from_path(curr_set) for curr_set in args.annotations} - {
None
}

Expand Down Expand Up @@ -227,8 +227,8 @@ def validate(args):
arg("source", help="project_path"),
arg("--format",
help="format to output to",
default="txt",
choices=['txt', 'csv']),
default="literal",
choices=['literal', 'csv']),
]
)
def sets_metadata(args):
Expand All @@ -237,16 +237,34 @@ def sets_metadata(args):
am = AnnotationManager(project)

sets = am.get_sets_metadata()
if 'method' not in sets:
sets['method'] = 'Undefined'
else:
sets['method'] = sets['method'].fillna('Undefined').replace('', 'Undefined')

if args.format == 'txt':
if args.format == 'literal':
output = ""
for row in sets.to_dict(orient='records') :
output += "\033[94m%s\033[0m: %.2f hours, %s\n" % (
row['set'], row['duration'] / (3600 * 1000), row)
methods = sets['method'].unique
for g, gdf in sets.groupby('method') :
output += "\n\033[1m{} ({:.2f} hours)\033[0m:\n".format(g, gdf['duration'].sum() / (3600 * 1000))
for row in gdf.to_dict(orient='records'):
if g == 'automated':
output += "\033[94m%s\033[0m: %s %.2f hours, algorithm:%s v%s (%s)\n" % (
row['set'], row['date_annotation'], row['duration'] / (3600 * 1000),
row['annotation_algorithm_name'], row['annotation_algorithm_version'],
row['annotation_algorithm_publication'])
elif g == 'human':
output += "\033[94m%s\033[0m: %s %.2f hours, algorithm:%s (experience %d/5)\n" % (
row['set'], row['date_annotation'], row['duration'] / (3600 * 1000),
row['annotator_name'], row['annotator_experience'])
else:
output += "\033[94m%s\033[0m: %.2f hours, %s\n" % (
row['set'], row['duration'] / (3600 * 1000), row)
logger.info(output)
if args.format == 'csv':
print(sets.to_csv(None, index=False))


@subcommand(
[
arg("source", help="project path"),
Expand Down

0 comments on commit 4f5a95b

Please sign in to comment.