Skip to content

Commit

Permalink
action --profile option
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi committed Jul 8, 2024
1 parent 80fd931 commit 55c0c18
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 12 additions & 2 deletions ckanapi/cli/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,18 @@ def action(ckan, arguments, stdin=None):
raise CLIError("argument not in the form KEY=STRING, "
"KEY:JSON or KEY@FILE %r" % kv)

result = ckan.call_action(arguments['ACTION_NAME'], action_args,
files=file_args, requests_kwargs=requests_kwargs)
def call():
return ckan.call_action(arguments['ACTION_NAME'], action_args,
files=file_args,
requests_kwargs=requests_kwargs)

if arguments['--profile']:
from cProfile import Profile
with Profile() as pr:
result = call()
pr.dump_stats(arguments['--profile'])
else:
result = call()

if arguments['--output-jsonl']:
if isinstance(result, list):
Expand Down
4 changes: 3 additions & 1 deletion ckanapi/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Usage:
ckanapi action ACTION_NAME
[(KEY=STRING | KEY:JSON | KEY@FILE ) ... | -i | -I JSON_INPUT]
[-j | -J]
[-j | -J] [-P PROFILE ]
[[-c CONFIG] [-u USER] | -r SITE_URL [-a APIKEY] [-g] [--insecure]]
ckanapi batch [-I JSONL_INPUT] [-s START] [-m MAX] [--local-files]
[-p PROCESSES] [-l LOG_FILE] [-qwz]
Expand Down Expand Up @@ -62,6 +62,8 @@
-o --update-only update existing records, don't create new records
-O --output=JSONL_OUTPUT output to json lines file instead of stdout
-p --processes=PROCESSES set the number of worker processes [default: 1]
-P --profile=PROFILE run action with cProfile and output to PROFILE
only local actions (no -r) will show internals
-q --quiet don't display progress messages
-r --remote=URL URL of CKAN server for remote actions
-R --resource-views export resource views information along with
Expand Down

0 comments on commit 55c0c18

Please sign in to comment.