diff --git a/+dj/+internal/AutoPopulate.m b/+dj/+internal/AutoPopulate.m index fd3f5bf0..b6f63c56 100755 --- a/+dj/+internal/AutoPopulate.m +++ b/+dj/+internal/AutoPopulate.m @@ -349,8 +349,8 @@ function cleanup(self, key) function jobKey = makeJobKey(self, key) - hash = dj.internal.hash(key); - jobKey = struct('table_name', self.className, 'key_hash', hash(1:32)); + jobKey = struct('table_name', self.className, ... + 'key_hash', key_hash(key)); end diff --git a/+dj/key_hash.m b/+dj/key_hash.m new file mode 100644 index 00000000..1f152d41 --- /dev/null +++ b/+dj/key_hash.m @@ -0,0 +1,7 @@ +% dj.key_hash - key hashing function for populate jobs, etc + +function s = key_hash(key) + s = dj.internal.hash(key); + s = s(1:32); +end + 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 00000000..9240bbe9 --- /dev/null +++ b/docs-parts/computation/06-distributed-computing_jobs_by_key.rst @@ -0,0 +1,37 @@ + +This can be done by using `dj.internal.hash` to convert the key as follows: + +.. code-block:: matlab + + > job_key = struct('table_name', 'Lab.SessionAnalysis', ... + 'key_hash', dj.key_hash(key)); + > Lab.Jobs() & job_key + + + ans = + + + Object Lab.Jobs + + :: the job reservation table for +Lab :: + + TABLE_NAME KEY_HASH status error_message user host pid connection_id timestamp key error_stack + _______________________ ____________________________________ ____________ _____________ ________ _________ __________ _____________ _______________________ __________ ___________ + + {'Lab.SessionAnalysis'} {'jA9sN_5PvusWwmznLGcAZbTn5pGtba-z'} {'error'} {0×0 char} {'datajoint@localhost'} {'localhost'} 6.5356e+05 1919 {'2021-01-22 23:50:07'} {'=BLOB='} {'=BLOB='} + + 1 tuples (0.127 s) + + > del(Lab.Jobs() & job_key; + + > Lab.Jobs() & job_key + + ans = + + + Object Lab.Jobs + + :: the job reservation table for +Lab :: + + 0 tuples (0.0309 s) + diff --git a/tests/test_schemas/+Lab/SessionAnalysis.m b/tests/test_schemas/+Lab/SessionAnalysis.m index 258f35fa..ed386c42 100644 --- a/tests/test_schemas/+Lab/SessionAnalysis.m +++ b/tests/test_schemas/+Lab/SessionAnalysis.m @@ -12,7 +12,7 @@ function makeTuples(self,key) r = sprintf('connection_id = %d', c.serverId); j = fetch(Lab.Jobs() & r, '*'); - + if isempty(j) key.session_analysis = key.session_id; else