Skip to content

Commit 892f736

Browse files
author
Chris Turner
authored
Merge pull request #327 from datajoint/external-storage
Add external storage, dj.config, and more
2 parents 4f2fdb9 + 456f17e commit 892f736

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+4634
-1394
lines changed

+dj/+config/load.m

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function load(fname)
2+
% LOAD(fname)
3+
% Description:
4+
% Updates the setting from config file in JSON format.
5+
% Inputs:
6+
% fname[optional, default=dj.internal.Settings.LOCALFILE]: (string) Config file path.
7+
% Examples:
8+
% dj.config.load('/path/to/dj_local_conf.json')
9+
% dj.config.load
10+
switch nargin
11+
case 0
12+
dj.internal.Settings.load();
13+
case 1
14+
dj.internal.Settings.load(fname);
15+
otherwise
16+
error('Exceeded 1 input limit.');
17+
end
18+
end

+dj/+config/restore.m

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function out = restore()
2+
% RESTORE()
3+
% Description:
4+
% Restores the configuration to initial default.
5+
% Examples:
6+
% dj.config.restore
7+
out = dj.internal.Settings.restore();
8+
end

+dj/+config/save.m

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function save(fname)
2+
% SAVE(fname)
3+
% Description:
4+
% Saves the settings in JSON format to the given file path.
5+
% Inputs:
6+
% fname[required]: (string) Config file path.
7+
% Examples:
8+
% dj.config.save('/path/to/dj_local_conf.json')
9+
switch nargin
10+
case 1
11+
dj.internal.Settings.save(fname);
12+
otherwise
13+
error('Requires 1 input.');
14+
end
15+
end

+dj/+config/saveGlobal.m

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function saveGlobal()
2+
% SAVEGLOBAL()
3+
% Description:
4+
% Saves the settings in the global config file.
5+
% Examples:
6+
% dj.config.saveGlobal
7+
dj.internal.Settings.saveGlobal();
8+
end

+dj/+config/saveLocal.m

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function saveLocal()
2+
% SAVELOCAL()
3+
% Description:
4+
% Saves the settings in the local config file.
5+
% Examples:
6+
% dj.config.saveLocal
7+
dj.internal.Settings.saveLocal();
8+
end

+dj/+internal/AutoPopulate.m

+12-6
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@
111111
%
112112
% See also dj.internal.AutoPopulate/parpopulate
113113

114-
if ~dj.set('populateAncestors')
114+
if ~dj.config('queryPopulate_ancestors')
115115
rels = {self};
116116
else
117117
% get all ancestors to be populated before self
118118
assert(nargout==0, ...
119-
'parpopulate cannot return output when populateAncestors is true')
119+
'parpopulate cannot return output when queryPopulate_ancestors is true')
120120
rels = cellfun(@feval, self.ancestors, 'uni', false);
121121
rels = rels(cellfun(@(x) isa(x,'dj.internal.AutoPopulate'), rels));
122122
end
@@ -149,8 +149,10 @@ function parpopulate(self, varargin)
149149
% key=null : blob # structure containing the key
150150
% error_message="" : varchar(1023) # error message returned if failed
151151
% error_stack=null : blob # error stack if failed
152+
% user="" : varchar(255) # database user
152153
% host="" : varchar(255) # system hostname
153154
% pid=0 : int unsigned # system process id
155+
% connection_id=0 : bigint unsigned # database connection id
154156
% timestamp=CURRENT_TIMESTAMP : timestamp # automatic timestamp
155157
%
156158
% A job is considered to be available when <package>.Jobs contains
@@ -171,7 +173,7 @@ function parpopulate(self, varargin)
171173
%
172174
% See also dj.internal.AutoPopulate/populate
173175

174-
if ~dj.set('populateAncestors')
176+
if ~dj.config('queryPopulate_ancestors')
175177
rels = {self};
176178
else
177179
% get all ancestors to be populated before self
@@ -375,7 +377,7 @@ function cleanup(self, key)
375377
success = false;
376378
end
377379
end
378-
if ~success && dj.set('verbose')
380+
if ~success && strcmpi(dj.config('loglevel'), 'DEBUG')
379381
fprintf('** %s: skipping already reserved\n', self.className)
380382
disp(key)
381383
end
@@ -390,8 +392,10 @@ function cleanup(self, key)
390392
catch
391393
[~,host] = system('hostname');
392394
end
395+
jobKey.user = self.schema.conn.user;
393396
jobKey.host = strtrim(host);
394397
jobKey.pid = feature('getpid');
398+
jobKey.connection_id = self.schema.conn.serverId;
395399
end
396400
if ismember('error_key', self.jobs.header.names)
397401
% for backward compatibility with versions prior to 2.6.3
@@ -420,8 +424,10 @@ function createJobTable(self)
420424
fprintf(f, 'key=null : blob # structure containing the key\n');
421425
fprintf(f, 'error_message="" : varchar(1023) # error message returned if failed\n');
422426
fprintf(f, 'error_stack=null : blob # error stack if failed\n');
427+
fprintf(f, 'user="" : varchar(255) # database user\n');
423428
fprintf(f, 'host="" : varchar(255) # system hostname\n');
424429
fprintf(f, 'pid=0 : int unsigned # system process id\n');
430+
fprintf(f, 'connection_id=0 : bigint unsigned # database connection id\n');
425431
fprintf(f, 'timestamp=CURRENT_TIMESTAMP : timestamp # automatic timestamp\n');
426432
fprintf(f, '%%}\n\n');
427433
fprintf(f, 'classdef Jobs < dj.Jobs\n');
@@ -433,8 +439,8 @@ function createJobTable(self)
433439
function populateSanityChecks(self)
434440
% Performs sanity checks that are common to populate,
435441
% parpopulate and batch_populate.
436-
% To disable the sanity check: dj.set('populateCheck',false)
437-
if dj.set('populateCheck')
442+
% To disable the sanity check: dj.config('queryPopulate_check',false)
443+
if dj.config('queryPopulate_check')
438444
source = self.getKeySource;
439445
abovePopRel = setdiff(self.primaryKey(1:min(end,length(source.primaryKey))), source.primaryKey);
440446
if ~all(ismember(source.primaryKey, self.primaryKey))

0 commit comments

Comments
 (0)