From bcd54706a033fb26a349fcc4000d96214aa59ccb Mon Sep 17 00:00:00 2001 From: Vishal-NEC <146080623+Vishal-NEC@users.noreply.github.com> Date: Tue, 12 Dec 2023 15:31:23 +0530 Subject: [PATCH 1/3] Added doc for ckan shell command in cli.rst --- doc/maintaining/cli.rst | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/doc/maintaining/cli.rst b/doc/maintaining/cli.rst index 0e1600f35f1..65e84700a16 100644 --- a/doc/maintaining/cli.rst +++ b/doc/maintaining/cli.rst @@ -93,6 +93,83 @@ with the ``--help`` option, for example: ckan -c |ckan.ini| user --help +------------------------------- +New CLI command: ckan shell +------------------------------- +The main goal to execute a ckan shell command is IPython session with the application loaded for easy debugging and dynamic coding. + +There are three variables already populated into the namespace of the shell: + +• **app** containing the Flask application +• **config** containing the CKAN config dictrionary +• **model** module to access to the database using SQLAlchemy syntax + +**command:** + +.. parsed-literal:: + $ ckan shell + +Example 1: +================ + +.. parsed-literal:: + + $ ckan shell + Python 3.9.13 (main, Dec 11 2022, 15:23:12) + Type 'copyright', 'credits' or 'license' for more information + + **In [1]:** model.User.all() + **Out[1]:** + [] + +.. parsed-literal:: + + **In [2]:** from ckan.logic.action.get import package_show + + **In [3]:** package_show({"model": model}, {"id": "api-package-1"}) + **Out[3]:** + {'author': None, + 'author_email': None, + 'creator_user_id': 'f0c04c11-4369-4cf1-9da4-69d9aae06a2e', + 'id': '922f3a91-c9ed-4e19-a722-366671b7d72c', + 'isopen': False, + 'license_id': None, + 'license_title': None, + 'maintainer': None, + 'maintainer_email': None, + 'metadata_created': '2022-06-16T14:13:37.736125', + 'metadata_modified': '2022-06-16T14:20:19.639665', + 'name': 'api-package-1', + 'notes': 'Update from API:10000', + 'num_resources': 0, + 'num_tags': 0, + 'organization': None, + 'owner_org': None, + 'private': False, + 'state': 'active', + 'title': 'api-package-1', + 'type': 'dataset', + 'url': None, + 'version': None, + 'resources': [], + 'tags': [], + 'extras': [], + 'groups': [], + 'relationships_as_subject': [], + 'relationships_as_object': []} + + +Example 2: +================ + +.. parsed-literal:: + + **In [7]:** from ckanext.activity.logic import action + **In [8]:** before = datetime.fromisoformat('2022-06-16T14:14:00.627446').timestamp() + **In [9]:** %timeit action.package_activity_list({}, {'id': 'api-package-1', 'before': before})3.17 ms ± 11.9 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) + **In [10]:** %timeit action.package_activity_list({}, {'id': 'api-package-1', 'offset': 9000})25.3 ms ± 504 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) + + ------------------------------- Troubleshooting ckan Commands From 2c6aad71c0aafc952ae9c9896741d7b0b2089f56 Mon Sep 17 00:00:00 2001 From: Vishal-NEC <146080623+Vishal-NEC@users.noreply.github.com> Date: Tue, 12 Dec 2023 16:04:18 +0530 Subject: [PATCH 2/3] Added doc for ckan shell command in cli.rst --- doc/maintaining/cli.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/maintaining/cli.rst b/doc/maintaining/cli.rst index 65e84700a16..41f523df662 100644 --- a/doc/maintaining/cli.rst +++ b/doc/maintaining/cli.rst @@ -94,7 +94,7 @@ with the ``--help`` option, for example: ckan -c |ckan.ini| user --help ------------------------------- -New CLI command: ckan shell +CLI command: ckan shell ------------------------------- The main goal to execute a ckan shell command is IPython session with the application loaded for easy debugging and dynamic coding. From 2a6f62666e232e0106c9dd1ecb44933b50f21420 Mon Sep 17 00:00:00 2001 From: Vishal Agrawal1 Date: Thu, 14 Dec 2023 11:51:56 +0530 Subject: [PATCH 3/3] ckan shell command in cli.rst --- changes/7402.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/7402.feature diff --git a/changes/7402.feature b/changes/7402.feature new file mode 100644 index 00000000000..43caf845e7f --- /dev/null +++ b/changes/7402.feature @@ -0,0 +1 @@ +update documenatation for CKAN SHELL command.