diff --git a/CHANGELOG.md b/CHANGELOG.md index 2714a0c4d..3ae977b60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### 0.13.0 -- TBD * Support DataJoint datatype and connection plugins (#715, #729) PR 730, #735 * Allow updating specified secondary attributes using `update1` PR #763 +* add dj.key_hash reference to dj.hash.key_hash, treat as 'public api' ### 0.12.8 -- Jan 12, 2021 * table.children, .parents, .descendents, and ancestors can return queryable objects. PR #833 diff --git a/datajoint/__init__.py b/datajoint/__init__.py index 6d5031fde..c26fc8435 100644 --- a/datajoint/__init__.py +++ b/datajoint/__init__.py @@ -24,7 +24,7 @@ 'Not', 'AndList', 'U', 'Diagram', 'Di', 'ERD', 'set_password', 'kill', 'MatCell', 'MatStruct', 'AttributeAdapter', - 'errors', 'DataJointError', 'key'] + 'errors', 'DataJointError', 'key', 'key_hash'] from .version import __version__ from .settings import config @@ -38,6 +38,7 @@ from .admin import set_password, kill from .blob import MatCell, MatStruct from .fetch import key +from .hash import key_hash from .attribute_adapter import AttributeAdapter from . import errors from .errors import DataJointError diff --git a/docs-parts/computation/06-distributed-computing_jobs_by_key.rst b/docs-parts/computation/06-distributed-computing_jobs_by_key.rst new file mode 100644 index 000000000..fbec4df41 --- /dev/null +++ b/docs-parts/computation/06-distributed-computing_jobs_by_key.rst @@ -0,0 +1,21 @@ + +This can be done by using `dj.key_hash` to convert the key as follows: + +.. code-block:: python + + In [4]: schema.jobs & {'key_hash' : dj.key_hash({'id': 2})} + Out[4]: + *table_name *key_hash status key error_message error_stac user host pid connection_id timestamp + +------------+ +------------+ +--------+ +--------+ +------------+ +--------+ +------------+ +-------+ +--------+ +------------+ +------------+ + __job_results c81e728d9d4c2f error =BLOB= KeyboardInterr =BLOB= datajoint@localhost localhost 15571 59 2017-09-04 14: + (Total: 1) + + In [5]: (schema.jobs & {'key_hash' : dj.key_hash({'id': 2})}).delete() + + In [6]: schema.jobs & {'key_hash' : dj.key_hash({'id': 2})} + Out[6]: + *table_name *key_hash status key error_message error_stac user host pid connection_id timestamp + +------------+ +----------+ +--------+ +--------+ +------------+ +--------+ +------+ +------+ +-----+ +------------+ +-----------+ + + (Total: 0) + diff --git a/docs-parts/computation/06-distributed-computing_kill_order_by.rst b/docs-parts/computation/06-distributed-computing_kill_order_by.rst index 9830b70ed..585f309fc 100644 --- a/docs-parts/computation/06-distributed-computing_kill_order_by.rst +++ b/docs-parts/computation/06-distributed-computing_kill_order_by.rst @@ -1,7 +1,7 @@ For example, to sort the output by hostname in descending order: -.. code-block:: text +.. code-block:: python In [3]: dj.kill(None, None, 'host desc') Out[3]: diff --git a/docs-parts/computation/06-distributed-computing_lang2.rst b/docs-parts/computation/06-distributed-computing_lang2.rst index d3a3338e1..2df361bf8 100644 --- a/docs-parts/computation/06-distributed-computing_lang2.rst +++ b/docs-parts/computation/06-distributed-computing_lang2.rst @@ -1,5 +1,5 @@ -.. code-block:: text +.. code-block:: python In [1]: schema.jobs Out[1]: diff --git a/docs-parts/computation/06-distributed-computing_lang3.rst b/docs-parts/computation/06-distributed-computing_lang3.rst index f4b840866..2a26bc51c 100644 --- a/docs-parts/computation/06-distributed-computing_lang3.rst +++ b/docs-parts/computation/06-distributed-computing_lang3.rst @@ -1,7 +1,7 @@ For example, if a Python process is interrupted via the keyboard, a KeyboardError will be logged to the database as follows: -.. code-block:: text +.. code-block:: python In [2]: schema.jobs Out[2]: diff --git a/docs-parts/computation/06-distributed-computing_lang4.rst b/docs-parts/computation/06-distributed-computing_lang4.rst index e8a98ae77..106fa51f1 100644 --- a/docs-parts/computation/06-distributed-computing_lang4.rst +++ b/docs-parts/computation/06-distributed-computing_lang4.rst @@ -1,7 +1,7 @@ For example, given the above table, errors can be inspected as follows: -.. code-block:: text +.. code-block:: python In [3]: (schema.jobs & 'status="error"' ).fetch(as_dict=True) Out[3]: diff --git a/docs-parts/computation/06-distributed-computing_lang5.rst b/docs-parts/computation/06-distributed-computing_lang5.rst index 3f27bda08..31ffaf493 100644 --- a/docs-parts/computation/06-distributed-computing_lang5.rst +++ b/docs-parts/computation/06-distributed-computing_lang5.rst @@ -1,6 +1,6 @@ For example: -.. code-block:: text +.. code-block:: python In [4]: (schema.jobs & 'status="error"' ).delete()