Skip to content

Commit

Permalink
* added possibility to log all used CK entries to find out all depend…
Browse files Browse the repository at this point in the history
…encies

turn on: ck set kernel --var.log_ck_entries={file}
turn off: ck set kernel --var.log_ck_entries=""
  • Loading branch information
gfursin committed Oct 11, 2019
1 parent 0d6c5bf commit 78c8d59
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 6 deletions.
8 changes: 7 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
* V1.11.3.1
* V1.11.4
* fixed problem when ck-python.cfg contains non-existent python
* fixed problem with allowed action_names
(should not start with number but can have numbers in the middle)
* fixed problem with ElasticSearch when renaming entries
* Added key "use_git_instead_of_https" to kernel cfg
to substitute https:// with git@ in repositories
* fixed problem with pip installation using Python 2.7
(thanks to Alex Redshaw from Arm)
* added possibility to log all used CK entries to find out all dependencies

turn on: ck set kernel --var.log_ck_entries={file}
turn off: ck set kernel --var.log_ck_entries=""

* V1.11.3
* minor clean up of the API doc
Expand Down
72 changes: 67 additions & 5 deletions ck/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# For example, we implemented some functions in Java, C, C++ and Fortran
# (see our xOpenME library used in Android)

__version__ = "1.11.3.1" # We use 3 digits for the main (released) version and 4th digit for development revision
# Do not use characters (to detect outdated version)!
__version__ = "1.11.4" # We use 3 digits for the main (released) version and 4th digit for development revision
# Do not use characters (to detect outdated version)!

# Extra modules global for the whole kernel
import sys
Expand Down Expand Up @@ -348,6 +348,8 @@
type_long=None # In Python 3 -> int, in Python 2 -> long
string_io=None # StringIO, which is imported differently in Python 2 and 3

log_ck_entries=False # If true, log CK entries to record all dependencies

##############################################################################
# Save CK state
#
Expand Down Expand Up @@ -2392,7 +2394,7 @@ def init(i): # pragma: no cover
}
"""

global cfg, work, initialized, paths_repos, type_long, string_io
global cfg, work, initialized, paths_repos, type_long, string_io, log_ck_entries

if initialized:
return {'return':0}
Expand Down Expand Up @@ -2605,6 +2607,10 @@ def init(i): # pragma: no cover
r=merge_dicts({'dict1':cfg, 'dict2':cfg1})
if r['return']>0: return r

# Check if need to log CK entries
if cfg.get('log_ck_entries','')!='':
log_ck_entries=True

initialized=True

return {'return':0}
Expand Down Expand Up @@ -3241,6 +3247,22 @@ def find_path_to_data(i):
# ralias=r['repo_alias']
# qmax=1

# Check logging of repo:module:uoa to be able to rebuild CK dependencies
if log_ck_entries:
lce=cfg.get('log_ck_entries','')
if lce!='':
rl=save_text_file({'text_file':lce,
'string':'"action":"find", "repo_uoa":"'+
ruoa+'", "repo_uid":"'+
ruid+'", "module_uoa":"'+
muoa+'", "module_uid":"'+
muid+'", "data_uoa":"'+
duoa+'", "data_uid":"'+
duid+'"\n',
'append':'yes'})
if rl['return']>0: return rl


return {'return':0, 'path':pd, 'path_module':pm, 'path_repo':pr,
'repo_uoa':ruoa, 'repo_uid':ruid, 'repo_alias':ralias,
'module_uoa':muoa, 'module_uid':muid, 'module_alias':malias,
Expand Down Expand Up @@ -3905,6 +3927,20 @@ def perform_action(i):
u=rx['dict']
p=rx['path']

# Check logging of repo:module:uoa to be able to rebuild CK dependencies
if log_ck_entries:
lce=cfg.get('log_ck_entries','')
if lce!='':
rl=save_text_file({'text_file':lce,
'string':'"action":"'+action+'", "repo_uoa":"'+
i.get('repo_uoa','')+'", "repo_module_uoa":"'+
repo_module_uoa+'", "module_uoa":"'+
xmodule_uoa+'", "module_uid":"'+
xmodule_uid+'", "data_uoa":"'+
i.get('data_uoa','')+'"\n',
'append':'yes'})
if rl['return']>0: return rl

declared_action = action in u.get('actions',{})
default_action_name = u.get('default_action_name','')
intercept_kernel = i.get('{}.intercept_kernel'.format(module_uoa),'')
Expand Down Expand Up @@ -7371,7 +7407,6 @@ def ren(i):

if is_uid(nduoa): nduid=nduoa
path='/'+muid+'/'+nduid+'/1'
print ('xyz2=',path)
ri=access_index_server({'request':'DELETE', 'path':path})
if ri['return']>0: return ri
ri=access_index_server({'request':'PUT', 'path':path, 'dict':rdd})
Expand Down Expand Up @@ -8235,6 +8270,20 @@ def list_data(i):
if not idnatl:
lst.append(ll)

if log_ck_entries:
lce=cfg.get('log_ck_entries','')
if lce!='':
rl=save_text_file({'text_file':lce,
'string':'"action":"list", "repo_uoa":"'+
ll.get('repo_uoa','')+'", "repo_uid":"'+
ll.get('repo_uid','')+'", "module_uoa":"'+
ll.get('module_uoa','')+'", "module_uid":"'+
ll.get('module_uid','')+'", "data_uoa":"'+
ll.get('data_uoa','')+'", "data_uid":"'+
ll.get('data_uid','')+'"\n',
'append':'yes'})
if rl['return']>0: return rl

if o=='con':
x=''
if iprf: x=ruoa+':'+muoa+':'
Expand Down Expand Up @@ -8438,7 +8487,6 @@ def search(i):
'out':'con'})
if ry['return']>0: return ry


# Restart local search
rr=search2(i)

Expand Down Expand Up @@ -8692,6 +8740,20 @@ def search2(i):
'data_uoa':duoa, 'data_uid':duid,
'path':path})

if log_ck_entries:
lce=cfg.get('log_ck_entries','')
if lce!='':
rl=save_text_file({'text_file':lce,
'string':'"action":"find", "repo_uoa":"'+
ruoa+'", "repo_uid":"'+
ruid+'", "module_uoa":"'+
muoa+'", "module_uid":"'+
muid+'", "data_uoa":"'+
duoa+'", "data_uid":"'+
duid+'"\n',
'append':'yes'})
if rl['return']>0: return rl

if o=='con':
x=ruoa+':'+muoa+':'
if sys.version_info[0]<3:
Expand Down

0 comments on commit 78c8d59

Please sign in to comment.