From 8d998146e29cd9dcbd424b6835bc2acd2b0937df Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Thu, 14 May 2020 22:04:58 +0100 Subject: [PATCH] remove garbage org files, move example config down the hierarchy --- TODO.org | 17 -------- demo.py | 2 +- doc/SETUP.org | 43 +++++++++---------- .../example_config}/my/config/__init__.py | 0 .../example_config}/my/config/repos/.gitkeep | 0 .../example_config}/my/config/repos/hypexport | 0 misc.org | 35 --------------- my/config/__init__.py | 2 +- 8 files changed, 23 insertions(+), 76 deletions(-) delete mode 100644 TODO.org rename {mycfg_template => doc/example_config}/my/config/__init__.py (100%) rename {mycfg_template => doc/example_config}/my/config/repos/.gitkeep (100%) rename {mycfg_template => doc/example_config}/my/config/repos/hypexport (100%) delete mode 100644 misc.org diff --git a/TODO.org b/TODO.org deleted file mode 100644 index 67b2f95..0000000 --- a/TODO.org +++ /dev/null @@ -1,17 +0,0 @@ -https://github.com/crowoy/Health-Analysis -https://github.com/joytafty-work/SleepModel -https://github.com/search?l=Jupyter+Notebook&q=s_awakenings&type=Code&utf8=%E2%9C%93 -https://github.com/oshev/colifer/blob/592cc6b4d1ac9005c52fccdfb4e207513812baaa/colifer.py -https://github.com/oshev/colifer/blob/592cc6b4d1ac9005c52fccdfb4e207513812baaa/reportextenders/jawbone/jawbone_sleep.py -https://github.com/GlenCrawford/ruby_jawbone - -* https://nyquist212.wordpress.com/2015/06/22/visualizing-jawbone-up-data-with-d3-js/ - - -* TODO ok, so shoud really do a week of consistent bedtime/waking up to make some final decision on jawbone? - -* TODO figure out timezones -* TODO post on reddit? release and ask people to run against their data? - - -* TODO [2019-12-19 Thu 19:53] hmm, if package isn't using mycfg then we don't really need it? diff --git a/demo.py b/demo.py index 88e7554..60e757c 100755 --- a/demo.py +++ b/demo.py @@ -31,7 +31,7 @@ def run(): # # 4. point my.config to the Hypothesis data - mycfg_root = abspath('my_repo/mycfg_template') + mycfg_root = abspath('my_repo/doc/example_config') init_file = Path(mycfg_root) / 'my/config/__init__.py' init_file.write_text(init_file.read_text().replace( '/path/to/hypothesis/data', diff --git a/doc/SETUP.org b/doc/SETUP.org index 687c106..d03e2a8 100644 --- a/doc/SETUP.org +++ b/doc/SETUP.org @@ -142,40 +142,39 @@ Since it's a Python package, generally it's very *flexible* and there are many w ~/.config/my/my/config/repos/rexport #+end_example -- Another example is in [[file:../mycfg_template][mycfg_template]]: +- Another example is in [[file:example_config][example_config]]: #+begin_src bash :exports results :results output - cd .. - for x in $(find mycfg_template/ | grep -v -E 'mypy_cache|.git|__pycache__|scignore'); do + for x in $(find example_config/ | grep -v -E 'mypy_cache|.git|__pycache__|scignore'); do if [[ -L "$x" ]]; then - echo "l $x -> $(readlink $x)" + echo "symlink | $x -> $(readlink $x)" elif [[ -d "$x" ]]; then - echo "d $x" + echo "dir | $x" else - echo "f $x" - (echo "---"; cat "$x"; echo "---" ) | sed 's/^/ /' + echo "file | $x" + (echo "---"; cat "$x"; echo "---" ) | sed 's/^/ /' fi done #+end_src #+RESULTS: #+begin_example - d mycfg_template/ - d mycfg_template/my - d mycfg_template/my/config - f mycfg_template/my/config/__init__.py - --- - """ - Feel free to remove this if you don't need it/add your own custom settings and use them - """ + dir | example_config/ + dir | example_config/my + dir | example_config/my/config + file | example_config/my/config/__init__.py + --- + """ + Feel free to remove this if you don't need it/add your own custom settings and use them + """ - class hypothesis: - # expects outputs from https://github.com/karlicoss/hypexport - # (it's just the standard Hypothes.is export format) - export_path = '/path/to/hypothesis/data' - --- - d mycfg_template/my/config/repos - l mycfg_template/my/config/repos/hypexport -> /tmp/my_demo/hypothesis_repo + class hypothesis: + # expects outputs from https://github.com/karlicoss/hypexport + # (it's just the standard Hypothes.is export format) + export_path = '/path/to/hypothesis/data' + --- + dir | example_config/my/config/repos + symlink | example_config/my/config/repos/hypexport -> /tmp/my_demo/hypothesis_repo #+end_example As you can see, generally you specify fixed paths (e.g. to your backups directory) in ~__init__.py~. diff --git a/mycfg_template/my/config/__init__.py b/doc/example_config/my/config/__init__.py similarity index 100% rename from mycfg_template/my/config/__init__.py rename to doc/example_config/my/config/__init__.py diff --git a/mycfg_template/my/config/repos/.gitkeep b/doc/example_config/my/config/repos/.gitkeep similarity index 100% rename from mycfg_template/my/config/repos/.gitkeep rename to doc/example_config/my/config/repos/.gitkeep diff --git a/mycfg_template/my/config/repos/hypexport b/doc/example_config/my/config/repos/hypexport similarity index 100% rename from mycfg_template/my/config/repos/hypexport rename to doc/example_config/my/config/repos/hypexport diff --git a/misc.org b/misc.org deleted file mode 100644 index 2d5283d..0000000 --- a/misc.org +++ /dev/null @@ -1,35 +0,0 @@ -Various thoughts on organizing - -* Importing external models -- First alternative: - @lru_cache() - def hypexport(): - ... import_file - - # doesn't really work either.. - # hypexport = import_file(Path(paths.hypexport.repo) / 'model.py') - - + TODO check pytest friendliness if some paths are missing? Wonder if still easier to control by manually excluding... - - not mypy/pylint friendly at all? - -- Second alternative: - symlinks in mycfg and direct import? - - + mypy/pylint friendly - ? keeping a symlink to model.py is not much worse than hardcoding path. so it's ok I guess - -* Thoughts on organizing imports -- First way: - import mycfg.hypexport_model as hypexport - works, but mycfg is scattered across the repository? - -Second way: - from . import mycfg? - doesn't seem to work with subpackages? - right, perhaps symlinking is a good idea after all?... - -Third way: - import mycfg.repos.hypexport.model as hypexport - works, but MYPYPATH doesn't seem to be happy... - ok, --namespace-packages solves it.. - diff --git a/my/config/__init__.py b/my/config/__init__.py index 333ae6e..735cc9e 100644 --- a/my/config/__init__.py +++ b/my/config/__init__.py @@ -1,7 +1,7 @@ # TODO ok, this thing should trigger .cfg import presumably?? from ..core import init -# TODO maybe, reuse mycfg_template here? +# TODO maybe, reuse example_config here? class stub: key = 'value'