Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 06-distributed-computing_jobs_by_key.rst (#259) #346

Open
wants to merge 4 commits into
base: stage
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions +dj/+internal/AutoPopulate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, to access it properly you should indicate the package as well:

Suggested change
'key_hash', key_hash(key));
'key_hash', dj.key_hash(key));

end


Expand Down
7 changes: 7 additions & 0 deletions +dj/key_hash.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
% dj.key_hash - key hashing function for populate jobs, etc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are adding to the code base, would you add a minimal test for taking the hash to maintain the coverage?

Also, would you remove this and add it properly in the function so that it works with help(...)? See here for an example.


function s = key_hash(key)
s = dj.internal.hash(key);
s = s(1:32);
end

37 changes: 37 additions & 0 deletions docs-parts/computation/06-distributed-computing_jobs_by_key.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

This can be done by using `dj.internal.hash` to convert the key as follows:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This can be done by using `dj.internal.hash` to convert the key as follows:
This can be done by using `dj.key_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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> del(Lab.Jobs() & job_key;
> del(Lab.Jobs() & job_key);


> Lab.Jobs() & job_key

ans =


Object Lab.Jobs

:: the job reservation table for +Lab ::

0 tuples (0.0309 s)

2 changes: 1 addition & 1 deletion tests/test_schemas/+Lab/SessionAnalysis.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function makeTuples(self,key)
r = sprintf('connection_id = %d', c.serverId);

j = fetch(Lab.Jobs() & r, '*');

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like whitespace was added by mistake...

Suggested change

if isempty(j)
key.session_analysis = key.session_id;
else
Expand Down