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

Using bulk insert without command / Click #26

Open
AubinMoreau opened this issue May 18, 2020 · 3 comments
Open

Using bulk insert without command / Click #26

AubinMoreau opened this issue May 18, 2020 · 3 comments

Comments

@AubinMoreau
Copy link

Hi, sorry to bother you with a question which is probably a simple one but is that possible (and if it is, how ?) to launch the code without using click or command and without giving every arguments ?

I just want to do this :
bulk_insert(graph, host, port, nodes, relations)

Without putting all parameters like this :
bulk_insert(graph, host, port, password, nodes, relations, separator, max_token_count, max_buffer_size, max_token_size, quote, field_types, skip_invalid_nodes, skip_invalid_edges)

But for now, the only way i found is (as you do on your test) by using Click :

from click.testing import CliRunner
from redisgraph_bulk_loader.bulk_insert import bulk_insert

def addToGraph(port,nodes,relations,graphName):
    runner = CliRunner()
    res = runner.invoke(bulk_insert, [
        "--port", port,
        "--nodes", nodes,
        "--relations", relations,
        graphName])

Thanks for your help.

@jeffreylovitz
Copy link
Contributor

Hi @AubinMoreau,

That is a good question that I had not previously considered!

The default arguments are set as Click options, then the actual parameters for bulk_insert does not have defaults:
https://github.com/RedisGraph/redisgraph-bulk-loader/blob/master/redisgraph_bulk_loader/bulk_insert.py#L362

As such, you currently cannot call bulk_insert without specifying all parameters, though this can easily be fixed by adding the appropriate defaults on the bulk_insert signature.

However, you will still encounter issues if avoiding Click entirely, because we use Click's progress bars to wrap CSV processing:
https://github.com/RedisGraph/redisgraph-bulk-loader/blob/master/redisgraph_bulk_loader/bulk_insert.py#L202

The bulk loader wasn't written to expose the function bulk_insert, so I expect your current approach will cause some problems. That said, it seems like a sensible strategy! I will give some thought to how to make Click optional and let bulk_insert work as a standalone function rather than just as a script.

@AubinMoreau
Copy link
Author

Thanks for your quick reply @jeffreylovitz !

I will continue to use click if there's no other way, i just didn't wanted to do it without exploring other options (if i get satified by the first solution i found, i won't progress).

Have a nice day !

@ghukill
Copy link

ghukill commented May 11, 2022

I'm curious if there has been any additional thought on using this utility from a python interperter context, vs calling as a command line option? more specifically, without using Click?

Or, if another approach for bulk loading has emerged since then?

Either way, it remains a great utility!

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

No branches or pull requests

3 participants