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

fix: Refactor marker in Neo4jStalenessRemovalTask #297

Closed
wants to merge 1 commit into from

Conversation

otakart
Copy link

@otakart otakart commented Jul 1, 2020

Summary of Changes

When milliseconds_to_expire is used to identify stale data, Neo4jStalenessRemovalTask passes marker with expression (timestamp() - {}).format(milliseconds_to_expire) as parameter to neo4j. Arbitrary expressions as parameters are not supported by neo4j.

This PR gets timestamp() value from neo4j and calculates marker as integer.

Tests

Modified tests/unit/task/test_neo4j_staleness_removal_task.py.

CheckList

Make sure you have checked all steps below to ensure a timely review.

  • PR title addresses the issue accurately and concisely. Example: "Updates the version of Flask to v1.0.2"
  • PR includes a summary of changes.
  • PR adds unit tests, updates existing unit tests, OR documents why no test additions or modifications are needed.
  • PR passes make test

@codecov-commenter
Copy link

codecov-commenter commented Jul 1, 2020

Codecov Report

Merging #297 into master will increase coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #297      +/-   ##
==========================================
+ Coverage   73.45%   73.57%   +0.12%     
==========================================
  Files         103      103              
  Lines        4328     4329       +1     
  Branches      403      403              
==========================================
+ Hits         3179     3185       +6     
+ Misses       1049     1044       -5     
  Partials      100      100              
Impacted Files Coverage Δ
databuilder/task/neo4j_staleness_removal_task.py 89.25% <100.00%> (+4.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ef5ab6...1496dd6. Read the comment docs.

@feng-tao
Copy link
Member

feng-tao commented Jul 1, 2020

hey @jinhyukchang could you take a look at this pr? thanks.

@jinhyukchang
Copy link
Contributor

@otakart Could you elaborate what you meant by "Arbitrary expressions as parameters are not supported by neo4j."? This is working in our Neo4j version "3.3.5", but I wonder if it's not working for you.

@otakart
Copy link
Author

otakart commented Jul 14, 2020

Hi @jinhyukchang ,
Thanks for checking the PR.
My motivation is that staleness removal was not working for me with MS_TO_EXPIRE. It was working fine with JOB_PUBLISH_TAG, but I need to identify stale records by age. I'm using neo4j version 3.3.9.

According to neo4j documentation https://neo4j.com/docs/cypher-manual/3.5/syntax/parameters/
there is a limited set of use cases for parameters. In MS_TO_EXPIRE case the parameter marker passed to neo4j is 'timestamp() - 1234' (where 1234 is value of MS_TO_EXPIRE) and this is interpreted as string literal by neo4j. It can be checked by running simple script:

from neo4j import GraphDatabase

host = '***'
user = '***'
pw = '***'

driver = GraphDatabase.driver(host, auth=(user, pw))
with driver.session() as session:
    res = session.run('return $param as result', param='timestamp() - 123')
    print(res.single())

the output is:

<Record result='timestamp() - 123'>

@stale
Copy link

stale bot commented Jul 29, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale stalebot believes this issue/PR is no longer active label Jul 29, 2020
@feng-tao feng-tao added the keep fresh Disables stalebot from closing an issue label Jul 29, 2020
@stale stale bot removed the stale stalebot believes this issue/PR is no longer active label Jul 29, 2020
@otakart
Copy link
Author

otakart commented Sep 2, 2020

Hi @jinhyukchang please let me know if you need any additional information. Thanks

@feng-tao
Copy link
Member

feng-tao commented Sep 4, 2020

ping @jinhyukchang

@feng-tao
Copy link
Member

feng-tao commented Oct 1, 2020

@otakart if you update the pr, I will take a look and merge it given @jinhyukchang is not available. Sorry for the wait

@otakart
Copy link
Author

otakart commented Oct 3, 2020

@feng-tao it looks like the issue has been solved by PR #307. So we can close this PR. Thanks

@feng-tao feng-tao closed this Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep fresh Disables stalebot from closing an issue
Projects
None yet
4 participants