[x] 所有 run 法不帶 selftest 跑一遍,準備要 release 的版本:
[x] 改 %USERPROFILE%\Documents\GitHub\peforth\quit.f
' <selftest> :: enabled=False
Run setup.bat 做出取消 selftest 的 wheel
[x] pip uninstall peforth
[x] pip install peforth-xxxx.whl <== 注意!用剛做好的 wheel 否則會上網抓。
[x] 1. python -i -m peforth [/] no-selftest .s words exit
[x] 2. python -i -m peforth version drop
[x] 3. python import peforth
[x] selftest peforth.ok() .s words <--- no parent
[x] 1234 bye check echo %errorlevel%
[x] 4. jupyter notebook --> .s cd help bye .s cd help exit
[x] 考慮 README.rst 改良
[x] 若有改過 README.rst 則 wheel 就要重做
--> quit.f selftest=False --> 重來
[x] 所有 run 法帶 selftest:
[x] 改 %USERPROFILE%\Documents\GitHub\peforth\quit.f
' <selftest> :: enabled=True
Run setup.bat 更新本地版本以供測試
[x] 1. python -i -m peforth [/] with-selftest .s words exit bye
[x] 2. ipython -i -m peforth .' Hello World!!' cr bye
[x] 3. ipython import peforth .s words
[x] selftest peforth.ok() .s words <--- w/parent
[x] 1234 bye check echo %errorlevel%
[x] 4. jupyter notebook --> .s cd help bye .s cd help exit
[x] 考慮 README.rst 改良
[x] 若有改過 README.rst 則 wheel 就要重做
--> quit.f selftest=False --> 重來
[x] version 改成 1.14 (必須跳過 1.10 會變成 1.1)
[x] Make a master release up to GitHub --> 用 GitHub Windows 很簡單。
[x] 讓 jupyter feature peforth --> 已經加進 jupyter 的 kernel list:
https://github.com/jupyter/jupyter/wiki/Jupyter-kernels
[/] Like harry_port that brings all wanted variables to projectk
How to make it easier?
[/] Study when deep in a certain module, how peforth find and bring in
specified variables?
1. debug the toy.. keras exercise, breakpoint deep in a keras module
2. instead of using the trick of loc={**locals(),**{'foo':foo,'bar':bar}}
try to find foo,bar actual parent
3. access volatile variables out of their scope may not be a good idea
but being able to access them at a peforth breakpoint is necessary.
tensor_shape is imported in C:\Users\hcche\AppData\Local\Programs\Python\Python36\Lib\site-packages\tensorflow\python\keras\_impl\keras\layers\wrappers.py
char input_shape <text> \ local variable
locals :> ['{0}'] constant {0}
__main__ :: peforth.projectk.{0}=v('{0}')
</text> :> format(pop()) dictate
char tf <text> \ global variable
__main__ :> {0} constant {0}
__main__ :: peforth.projectk.{0}=v('{0}')
</text> :> format(pop()) dictate
* 1. char foobar module ( module )
2. py: setattr(sys.modules['foobar'].projectk,'foobar',v('foobar')) \ add to peforth
* 1. import numpy constant np // ( -- numpy ) module object, method 1
py> sys.modules['numpy'] constant np // ( -- numpy ) method 2
__main__ :> np constant np // ( -- numpy ) method 3
2. np __main__ :: peforth.projectk.np=pop(1) \ peforth global
np __main__ :: np=pop(1) \ __main__ global, see 'help __main__'
* 3. py: setattr(sys.modules['peforth'].projectk,'np',v('np')) \ alt method
char child_input_shape <text> \ local variable
locals :> ['{0}'] constant {0}
__main__ :: peforth.projectk.{0}=v('{0}')
</text> :> format(pop()) dictate
\ make librosa a global in peforth
char librosa py> tick(tos()) execute py: globals()[pop()]=pop()
\ even simpler way
import librosa constant librosa char librosa librosa py: globals()[pop()]=pop()
char input_shape <text> \ local variable
locals :> ['{0}'] constant {0}
__main__ :: peforth.projectk.{0}=v('{0}')
</text> :> format(pop()) dictate
char tensor_shape <text> \ local variable
locals :> ['{0}'] constant {0}
__main__ :: peforth.projectk.{0}=v('{0}')
</text> :> format(pop()) dictate
char selfLayer <text> \ local variable
locals :> ['{0}'] constant {0}
__main__ :: peforth.projectk.{0}=v('{0}')
</text> :> format(pop()) dictate
import peforth [/] _debug_
peforth.ok(cmd='''
0 value Count
none value child_output_shape
exit
''')
try:
child_output_shape = child_output_shape.as_list()
except Exception as err:
peforth.ok('33> ',loc={**locals(),**{'tensor_shape':tensor_shape,'self.layer':self.layer,'err':err}})
locals :: pop('peforth') locals inport
tensor_shape :> TensorShape(v('input_shape')).as_list() constant input_shape2
tensor_shape :> TensorShape([v('input_shape2')[0]]+v('input_shape2')[2:])
constant child_input_shape
self.layer :> _compute_output_shape(v('child_input_shape')) tib. \ ==> (?, 2048) (<class 'tensorflow.python.framework.tensor_shape.TensorShape'>)
self.layer :> _compute_output_shape(v('child_input_shape')) tib. \ ==> (?, 2048) (<class 'tensorflow.python.framework.tensor_shape.TensorShape'>)
self.layer :> _compute_output_shape(v('child_input_shape')) tib. \ ==> None (<class 'NoneType'>)
self.layer :> _compute_output_shape(v('child_input_shape')) tib. \ ==> None (<class 'NoneType'>)
[x] jupyter notebook 裡無法 exit , 每次 exit 都會留下一個東西在 stack 裡,出不去。
load> exit
load> .s
0: <IPython.core.autocall.ZMQExitAutocall object at 0x0000020577BF5EF0> (<class 'IPython.core.autocall.ZMQExitAutocall'>)
load>
--> 用 .py 比較看看 --> 沒這問題。
--> 直接進去,直接出來看看 --> 馬上卡住了。
--> 簡化 the peforth cell, 比較結果 ... 在 locals inport 之後多出一個 exit
看起來還是原來的 exit 但多出來就是不對,而且 --- marker clean up 之後好了!
充分證明就是它。
--> 怎麼發生的?--> ipython case 下,當時的 locals() 就是有 exit quit 等一堆東西
正好 exit 撞上了,而 locals :> ['exit'] . cr --> <IPython.core.autocall.ZMQExitAutocall object at 0x000001DBB24B5EF0>
正是那個怪東西。
RI
[/] 最好 inport 能用挑的。程序如下:
load2> locals keys . cr
dict_keys(['__name__', '__doc__', '__package__', '__loader__', '__spec__', '__builtin__', '__builtins__', '_ih', '_oh', '_dh', 'In', 'Out', 'get_ipython', 'exit', 'quit', '_', '__', '___', '_i', '_ii', '_iii', '_i1', 'tf', '_i2', 'tflearn', '_i3', 'speech_data', '_i4', 'time', 'peforth', 'epoch_count', 'learning_rate', 'training_iters', 'batch_size', 'width', 'height', 'classes', '_i5', 'batch', 'word_batch', '_i6', 'net', 'model', 'x', '_i7'])
\ 從上表裡面挑要用的東西
<py> ['get_ipython', 'tflearn', 'speech_data', 'time', 'epoch_count',
'learning_rate', 'training_iters', 'batch_size', 'width', 'height',
'classes', 'batch', 'word_batch', 'net', 'model', 'x']
</pyV> ( [挑過的keys] )
\ 從 locals 裡面挑這些東西出來
<py> dict([(k,v) for k,v in v('locals').items() if k in tos()])
</pyV> nip ( {挑過的locals} )
\ 可以放心地 inport 成 peforth words 了
inport
[ ] python virtualenv http://docs.python-guide.org/en/latest/dev/virtualenvs/
解決的問題也是 FORTH 的問題,參考人家怎麼解的,可以想想怎麼沿用,看如何只 include 必要的東西。
[x] Ubuntu 的問題好像有解了,
--> Ubuntu 之下
OK site :> USER_BASE . cr 不存在!
/home/hcchen5600/.local
OK site :> USER_SITE . cr 不存在!
/home/hcchen5600/.local/lib/python3.6/site-packages
OK site :> PREFIXES . cr
['/usr', '/usr']
實際東西放在
site.PREFIXES[0] + /local/lib/site-packages/peforth/
--> windows
OK site :> USER_BASE . cr 不存在!
C:\Users\hcche\AppData\Roaming\Python
OK site :> USER_SITE . cr 不存在!
C:\Users\hcche\AppData\Roaming\Python\Python36\site-packages
OK site :> PREFIXES . cr
['C:\\Users\\hcche\\AppData\\Local\\Programs\\Python\\Python36', 'C:\\Users\\hcche\\AppData\\Local\\Programs\\Python\\Python36']
實際東西放在
site.PREFIXES[0] + /lib/site-packages/peforth/
--> Ubuntu virtualenv
>>> import site
>>> site.PREFIXES
['/home/hcchen5600/GitHub/DeepSpeech', '/home/hcchen5600/GitHub/DeepSpeech']
>>> site.USER_BASE
'/home/hcchen5600/.local'
>>> site.USER_SITE
'/home/hcchen5600/.local/lib/python3.6/site-packages'
實際東西放在
site.PREFIXES[0] + /lib/site-packages/peforth/
也就是
\rootfs\home\hcchen5600\GitHub\DeepSpeech\lib\site-packages\peforth\..
\ Windows 下可 normalize the path
照上面實施, windows 下變成
OK py> path . cr
C:\Users\hcche\AppData\Local\Programs\Python\Python36/lib/site-packages/peforth/
\ 這可以用 ntpath.normpath() 解決
OK import ntpath
OK constant ntpath
OK ntpath dir . cr
['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_get_bothseps', '_getfinalpathname', '_getfullpathname', '_getvolumepathname', 'abspath', 'altsep', 'basename', 'commonpath', 'commonprefix', 'curdir', 'defpath', 'devnull', 'dirname', 'exists', 'expanduser', 'expandvars', 'extsep', 'genericpath', 'getatime', 'getctime', 'getmtime', 'getsize', 'isabs', 'isdir', 'isfile', 'islink', 'ismount', 'join', 'lexists', 'normcase', 'normpath', 'os', 'pardir', 'pathsep', 'realpath', 'relpath', 'samefile', 'sameopenfile', 'samestat', 'sep', 'split', 'splitdrive', 'splitext', 'splitunc', 'stat', 'supports_unicode_filenames', 'sys']
OK ntpath :> normpath . cr
<function normpath at 0x000001C511337E18>
OK ntpath :> normpath py: help(pop())
Help on function normpath in module ntpath:
normpath(path)
Normalize path, eliminating double slashes, etc.
OK py> path ntpath :> normpath(pop()) . cr
C:\Users\hcche\AppData\Local\Programs\Python\Python36\lib\site-packages\peforth
OK
\ 或者檢查看是否 Windows
In [8]: sys.modules.get('nt') <--- None 就是沒有,就不是 windows
In [9]: sys.modules.get('sys')
Out[9]: <module 'sys' (built-in)>
In [10]:
\ 更好的方法, yeah! this is it.
-- ubuntu --
In [12]: os.name
Out[12]: 'posix'
-- windows --
OK os :> name . cr
nt
[/] 有了這個 solution 連 jupyter peforth kernel 的 install 都可以自動化了。
[x] Ubuntu 的問題應該已經解決了,要推廣 peforth 必須趕快 release