Skip to content

Commit

Permalink
Add a bit more content on Python API
Browse files Browse the repository at this point in the history
  • Loading branch information
adswa committed Oct 6, 2023
1 parent 71459aa commit 9cbe673
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/basics/101-130-yodaproject.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,28 @@ a Python API for DataLad's functionality that you can read about in :ref:`a Find
As the Python API does not suffer from the startup time cost of the command line,
there is the potential for substantial speed-up when doing many calls to the API,
and using a persistent Dataset object instance.
You will also notice that the output of Python commands can be more verbose as the result records returned by each command do not get filtered by command-specific result renderers.
Thus, the outcome of ``dl.status('myfile')`` matches that of :dlcmd:`status` only when ``-f``/``--output-format`` is set to ``json`` or ``json_pp``, as illustrated below.

.. code-block:: python
>>> import datalad.api as dl
>>> dl.status('myfile')
[{'type': 'file',
'gitshasum': '915983d6576b56792b4647bf0d9fa04d83ce948d',
'bytesize': 85,
'prev_gitshasum': '915983d6576b56792b4647bf0d9fa04d83ce948d',
'state': 'clean',
'path': '/home/me/my-ds/myfile',
'parentds': '/home/me/my-ds',
'status': 'ok',
'refds': '/home/me/my-ds',
'action': 'status'}]
.. code-block:: bash
$ datalad -f json status myfile
{"action": "status", "bytesize": 85, "gitshasum": "915983d6576b56792b4647bf0d9fa04d83ce948d", "parentds": "/home/me/my-ds", "path": "/home/me/my-ds/myfile", "prev_gitshasum": "915983d6576b56792b4647bf0d9fa04d83ce948d", "refds": "/home/me/my-ds/", "state": "clean", "status": "ok", "type": "file"}
.. importantnote:: Use DataLad in languages other than Python

Expand Down

0 comments on commit 9cbe673

Please sign in to comment.