Skip to content

Commit a010ac0

Browse files
committed
gbd interactive command
1 parent c7670a3 commit a010ac0

2 files changed

Lines changed: 29 additions & 12 deletions

File tree

gbd.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ def cli_get(api: GBD, args):
8484
for index, row in df.iterrows():
8585
print(args.delimiter.join([ item or "[None]" for item in row.to_list() ]))
8686

87+
def cli_interactive(api: GBD, args):
88+
data = api.query(args.query, args.hashes, args.resolve, args.collapse, args.group_by, args.join_type)
89+
if args.group_by:
90+
data.set_index(args.group_by, inplace=True)
91+
else:
92+
data.set_index('hash', inplace=True)
93+
import IPython
94+
IPython.embed(header ="GBD data is available as `data`", colors="neutral")
95+
8796
def cli_set(api: GBD, args):
8897
hashes = api.query(args.query, args.hashes)['hash'].tolist()
8998
if args.create:
@@ -187,6 +196,17 @@ def main():
187196
parser_get.add_argument('-H', '--header', action='store_true', help='Include header information in output')
188197
parser_get.set_defaults(func=cli_get)
189198

199+
# GBD INTERACTIVE $QUERY
200+
parser_interactive = subparsers.add_parser('interactive', help='Get data by query (or hash-list via stdin) and open interactive Python prompt')
201+
add_query_and_hashes_arguments(parser_interactive)
202+
parser_interactive.add_argument('-r', '--resolve', help='List of feature names to resolve against', nargs='+', default=[])
203+
parser_interactive.add_argument('-c', '--collapse', default='group_concat',
204+
choices=['group_concat', 'min', 'max', 'avg', 'count', 'sum', 'none'],
205+
help='Specify a function for the handling of multiple feature values')
206+
parser_interactive.add_argument('-g', '--group_by', default=None, help='Group by the specified feature as the key, rather than by the primary key')
207+
parser_interactive.add_argument('--join-type', help='Join Type: treatment of missing values', choices=['INNER', 'OUTER', 'LEFT'], default="LEFT")
208+
parser_interactive.set_defaults(func=cli_interactive)
209+
190210
# GBD SET
191211
parser_set = subparsers.add_parser('set', help='Set specified attribute-value for query result')
192212
parser_set.add_argument('assign', type=key_value_type, help='key=value')

pyproject.toml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,17 @@ description = "GBD Tools: Maintenance and Distribution of Benchmark Instances an
99
readme = "README.md"
1010
license-files = ["LICENSE"]
1111
requires-python = ">=3.6"
12-
authors = [
13-
{ name = "Markus Iser", email = "markus.iser@kit.edu" }
14-
]
12+
authors = [{ name = "Markus Iser", email = "markus.iser@kit.edu" }]
1513
urls = { Homepage = "https://github.com/Udopia/gbd" }
16-
classifiers = [
17-
"Programming Language :: Python :: 3"
18-
]
14+
classifiers = ["Programming Language :: Python :: 3"]
1915
dependencies = [
20-
"flask",
21-
"tatsu",
22-
"pandas",
23-
"waitress",
24-
"pebble",
25-
"gbdc"
16+
"flask",
17+
"tatsu",
18+
"pandas",
19+
"waitress",
20+
"pebble",
21+
"gbdc",
22+
"IPython",
2623
]
2724
scripts = { gbd = "gbd:main" }
2825

0 commit comments

Comments
 (0)