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

FEAT(index) add --sources & --overwrite to CLI to partially update db from config sources #211

Merged
merged 5 commits into from
Mar 7, 2021

Conversation

ankostis
Copy link
Contributor

@ankostis ankostis commented Feb 28, 2021

Fixes #20

new --sources option(s)

  • args can be both Source.name & Source's positional index.
  • useful with dynamic partial updates, below (now the default), so that the original config file ca be used.

new --overwrite option

  • Added a single CLI option almost-described in the 2nd alternative case explained below,
    due to simplicity. if missing, defaults to "dynamic partial updates" as described in this and this.
  • Dropped PROMNESIA_INDEX_POLICY env-var, since it is the default behavior now.
  • Function defaults for --overwrite are False, as suggested in the comment below.
  • Both promnesia index & promnesia demo sub-commands have been updated.
  • All update/overwrite decision logic moved to promnesia/__main__.py.:

Various

  • Fix: create db-output directory in advance.

@ankostis
Copy link
Contributor Author

ankostis commented Mar 1, 2021

I'd like to add here more commits, to implement a new CLI option --update --overwrite <policy> from #20, where <policy> can be:

  • yes: delete & recreate promnesia db with newly indexed visits
  • no: keep existing visits and merge new ones collected
  • if_partial: (default when option is missing) update when --sources has been given, overwrite otherwise

Also documentation is missing (and a CHANGES.md would be good to have file).

@ankostis
Copy link
Contributor Author

ankostis commented Mar 1, 2021

Another alternative would be to add just 2 mutual-exclusive options: --update & --overwrite, which would be terser for users. But the previous syntax is more extendable, if in the future a new policy appears.

If will implement this, and await feedback.

ankostis added a commit to ankostis/promnesia that referenced this pull request Mar 1, 2021
- CLI options described in the 2nd case explained in karlicoss#211,
  due to simplicity.
- The precedence for deciding update/overwrite:
  env-var, --update/overwrite, --source exist?
- Function defaults are false, as suggested in
  [karlicoss#20](karlicoss#20 (comment)).
- Both index & demo updated.
- Env-var now checks its value one of (update|overwrite).
- All update/overwrite decision logic moved to __main_.
@ankostis
Copy link
Contributor Author

ankostis commented Mar 1, 2021

Implemented the 2nd alternative (and updated OP above with the new feature).

@ankostis
Copy link
Contributor Author

ankostis commented Mar 1, 2021

This PR is now only missing the docs & examples, and at the moment has taken the following design choices:

Added --update / --overwrite mutual exclusive options

  • Added the CLI options described in the 2nd alternative case explained below,
    due to simplicity.
  • The precedence for deciding whether to update or overwrite:
    • env-var PROMNESIA_INDEX_POLICY (now strick-check its value is one of (update|overwrite), case-insensitevely)
    • --update / --overwrite from CLI
    • --sources given? (--update conveyed)
    • --overwrite as fall-back (changing this would be a breaking change).
  • Function defaults in the new code are False, as suggested in this comment of #20.
  • Both promnesia index & promnesia demo sub-commands have been updated.
  • Env-var now checks its value one of (update|overwrite).
  • All update/overwrite decision logic moved to main.

ankostis added a commit to ankostis/promnesia that referenced this pull request Mar 1, 2021
- CLI options described in the 2nd case explained in karlicoss#211,
  due to simplicity.
- The precedence for deciding update/overwrite:
  env-var, --update/overwrite, --source exist?
- Function defaults are false, as suggested in
  [karlicoss#20](karlicoss#20 (comment)).
- Both index & demo updated.
- Env-var now checks its value one of (update|overwrite).
- All update/overwrite decision logic moved to __main_.
@karlicoss
Copy link
Owner

Hm, CI fails (for the context, this

- run: bash scripts/ci/run
is the script that github actions are running), but in essence, you can reproduce it localy via CI=true tox.

You can also run specific parts of tox as for example CI=true tox -e tests
https://github.com/karlicoss/promnesia/blob/master/tox.ini#L14

But also of course running tests directly with pytest would work too, guess you'll figure this out. But tox is the closest approximation to CI.

@karlicoss
Copy link
Owner

PROMNESIA_INDEX_POLICY

To be honest, I think it would make sense to deprecate it (not a major violation of backwards compatibility, doubt many people used it either). But maybe nice to add a warning.warn to start with.

src/promnesia/__main__.py Outdated Show resolved Hide resolved
src/promnesia/dump.py Outdated Show resolved Hide resolved
src/promnesia/__main__.py Outdated Show resolved Hide resolved
src/promnesia/__main__.py Outdated Show resolved Hide resolved
@karlicoss
Copy link
Owner

Thanks! Left some comments..
Btw think I noticed an issue recently -- I increased the frequency of updates and sometimes noticed that backend is unresponsinve (likely during DB updates). Not directly related to this PR, just something to keep in mind for the future (since --update makes sense as default)

ankostis added a commit to ankostis/promnesia that referenced this pull request Mar 2, 2021
- CLI options described in the 2nd case explained in karlicoss#211,
  due to simplicity.
- The precedence for deciding update/overwrite:
  env-var, --update/overwrite, --source exist?
- Function defaults are false, as suggested in
  [karlicoss#20](karlicoss#20 (comment)).
- Both index & demo updated.
- Env-var now checks its value one of (update|overwrite).
- All update/overwrite decision logic moved to __main_.
@ankostis
Copy link
Contributor Author

ankostis commented Mar 2, 2021

A kind request, when it's time to merge (not yet), i suggest to rebase this PR - not to squash it,
in order to preserve the commits herein, since they are articulated and isolated as "features", well described accordingly on each commit-message.

@karlicoss
Copy link
Owner

i suggest to rebase this PR - not to squash it,

Yes! I have a similar workflow, and happy to do that when people maintain clean history. I think I squashed your first PR since it had lots of 'fix' commits, but the other one I just rebased as is.

ankostis added a commit to ankostis/promnesia that referenced this pull request Mar 3, 2021
- CLI options described in the 2nd case explained in karlicoss#211,
  due to simplicity.
- The precedence for deciding update/overwrite:
  env-var, --update/overwrite, --source exist?
- Function defaults are false, as suggested in
  [karlicoss#20](karlicoss#20 (comment)).
- Both index & demo updated.
- Env-var now checks its value one of (update|overwrite).
- All update/overwrite decision logic moved to __main_.
@ankostis
Copy link
Contributor Author

ankostis commented Mar 3, 2021

More work...

To be honest, I think it would make sense to deprecate PROMNESIA_INDEX_POLICY (not a major violation of backwards compatibility, doubt many people used it either). But maybe nice to add a warning.warn to start with.
...
(since --update makes sense as default)

  • ok, 2d5c3c4 dropped --update option (only --overwrite remains), as "update" is now the default behavior, and
  • therefore removed that env-var completely, since if anyone had used PROMNESIA_INDEX_POLICY=update,
    won't notice any difference
    (assuming nobody used PROMNESIA_INDEX_POLICY=no, and decided that notifying user about this experimental feature being dropped, didn't worth its weight).
  • Now --sources option is uncoupled from --overwrite (much simpler CLI to grasp).
  • OP has been updated to reflect the final functionality of this PR.

Still owing ...

@ankostis ankostis changed the title FEAT(index) add --sources CLI to run just a subset of sources in config FEAT(index) add --sources & --overwrite to CLI to partially update db from config sources Mar 3, 2021
@karlicoss
Copy link
Owner

For #213 -- will respond there
For changelog -- yeah I agree. Let's discuss at #215

ankostis added a commit to ankostis/promnesia that referenced this pull request Mar 5, 2021
as suggested in karlicoss#20:

- drop PROMNESIA_INDEX_POLICY env-var.
- CLI options described in the 2nd case explained in karlicoss#211,
  due to simplicity.
- Function defaults are false, as suggested in
  [karlicoss#20](karlicoss#20 (comment)).
- Both index & demo updated.
- Env-var now checks its value one of (update|overwrite).
- All update/overwrite decision logic moved to __main_.
src/promnesia/__main__.py Outdated Show resolved Hide resolved
src/promnesia/__main__.py Show resolved Hide resolved
ankostis added a commit to ankostis/promnesia that referenced this pull request Mar 6, 2021
as suggested in karlicoss#20:

- drop PROMNESIA_INDEX_POLICY env-var.
- CLI options described in the 2nd case explained in karlicoss#211,
  due to simplicity.
- Function defaults are false, as suggested in
  [karlicoss#20](karlicoss#20 (comment)).
- Both index & demo updated.
- Env-var now checks its value one of (update|overwrite).
- All update/overwrite decision logic moved to __main_.
@ankostis ankostis force-pushed the src-subset branch 2 times, most recently from ea2f66f to ce58ab4 Compare March 6, 2021 19:08
src/promnesia/__main__.py Outdated Show resolved Hide resolved
src/promnesia/__main__.py Show resolved Hide resolved
ankostis added a commit to ankostis/promnesia that referenced this pull request Mar 6, 2021
as suggested in karlicoss#20:

- drop PROMNESIA_INDEX_POLICY env-var.
- CLI options described in the 2nd case explained in karlicoss#211,
  due to simplicity.
- Function defaults are false, as suggested in
  [karlicoss#20](karlicoss#20 (comment)).
- Both index & demo updated.
- Env-var now checks its value one of (update|overwrite).
- All update/overwrite decision logic moved to __main_.
as suggested in karlicoss#20:

- drop PROMNESIA_INDEX_POLICY env-var.
- CLI options described in the 2nd case explained in karlicoss#211,
  due to simplicity.
- Function defaults are false, as suggested in
  [karlicoss#20](karlicoss#20 (comment)).
- Both index & demo updated.
- Env-var now checks its value one of (update|overwrite).
- All update/overwrite decision logic moved to __main_.
add also --dry into `promnesia demo` sub-command.
@karlicoss karlicoss merged commit 0703ffa into karlicoss:master Mar 7, 2021
karlicoss pushed a commit that referenced this pull request Mar 7, 2021
as suggested in #20:

- drop PROMNESIA_INDEX_POLICY env-var.
- CLI options described in the 2nd case explained in #211,
  due to simplicity.
- Function defaults are false, as suggested in
  [#20](#20 (comment)).
- Both index & demo updated.
- Env-var now checks its value one of (update|overwrite).
- All update/overwrite decision logic moved to __main_.
@karlicoss
Copy link
Owner

karlicoss commented Mar 7, 2021

Hooray, thanks!

Sorry it's taken a while, I guess todos for me which would make it quicker next time:

  • make github actions run on pull requests & forks
  • add a section to development.org about running tests (tox/mypy/ -k argument) & basic explanation of what's in each of them (maybe even docstring is good enough) + mention submodules update command explicitly
  • (maybe) get rid of circleci in favor of github actions, just less external dependencies and makes it easier to run on forks as well

I'll look at it after I get some sleep (crazy schedule)

Other todos from the discussions:

  • add meaningful test for update functionality (I can do it and share the PR?)
    in particular, there might be a minor race condition (database unresponsive during the update), would be nice to cover it with regression test
  • add some basic cli tests
  • think about unifying cli commands in the future, since they all kind of do similar things

Not sure if forgot anything?

karlicoss added a commit that referenced this pull request Mar 8, 2021
karlicoss added a commit that referenced this pull request Mar 8, 2021
karlicoss added a commit that referenced this pull request Mar 8, 2021
@karlicoss
Copy link
Owner

Done the CI updates & developer info! #217 keeping circle though, since it's still useful because of systemd test.

Also if you go to “Actions” tab on your promnesia fork and click “I understand my workflows, go ahead and enable them”, the pipelines should start running for you even before you PR, so hopefully will make it all quicker next time.

karlicoss added a commit that referenced this pull request Mar 11, 2021
karlicoss added a commit that referenced this pull request Mar 11, 2021
karlicoss added a commit that referenced this pull request Mar 21, 2021
@ankostis ankostis deleted the src-subset branch March 30, 2021 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

real time indexing
2 participants