uva-bi-sdad / GHOST.jl

Tool for collecting GitHub data about Open Source Repositories and Contributors
https://uva-bi-sdad.github.io/GHOST.jl/dev/
ISC License
5 stars 0 forks source link

Could you provide more info on setting up the package? #17

Closed vlad43210 closed 3 years ago

vlad43210 commented 3 years ago

I'm very intrigued by this package and have tried to set it up! Got my Docker container working and have loaded the package in Julia. However, when I try setup() I get the error:

ERROR: ArgumentError: No PAT was provided nor available in the database.
Stacktrace:
 [1] setup(; host::String, port::String, dbname::String, user::String, password::String, schema::String, pats::Nothing) at /home/vscode/.julia/packages/GHOST/dIqhL/src/01_BaseUtils.jl:172
 [2] setup() at /home/vscode/.julia/packages/GHOST/dIqhL/src/01_BaseUtils.jl:154
 [3] top-level scope at REPL[4]:1
caused by [exception 1]
ArgumentError: Collection is empty, must contain exactly 1 element
Stacktrace:
 [1] only(::Array{GitHubPersonalAccessToken,1}) at ./iterators.jl:1295
 [2] setup(; host::String, port::String, dbname::String, user::String, password::String, schema::String, pats::Nothing) at /home/vscode/.julia/packages/GHOST/dIqhL/src/01_BaseUtils.jl:170
 [3] setup() at /home/vscode/.julia/packages/GHOST/dIqhL/src/01_BaseUtils.jl:154
 [4] top-level scope at REPL[4]:1

The examples I've seen in your repo just call setup() with no arguments. Do I need to provide an access token as an argument? If so, could I ask you to provide some sample syntax? Thank you in advance!!

Nosferican commented 3 years ago

Greetings! I should make the error message a bit more informative. The first time setup was called it created the tables in the database. It will then try to read of the pat table the for getting the GitHub personal access tokens available to use. You can pass a Vector{GitHubPersonalAccessToken} to setup as a keyword argument. See the example used for the CI https://github.com/uva-bi-sdad/GHOST.jl/blob/4c7bcd6d21afee3dcb83868bb06f6ff519ffea4e/test/runtests.jl#L3-L5

In that example, the PAT are passed as secrets to the environment. For a persistent database you could do something like

pats = GitHubPersonalAccessToken.(["login1", "login2"], ["token1", "token2"]) # Could just be one.
setup(pats = pats)

The login/token will then be stored on the table in the database and will be used when needed without having to provide it every time.

To obtain a GitHub Personal Access Token you can follow the instructions here.

vlad43210 commented 3 years ago

Thank you that is perfect. Using this explanation, I have been able to get my instance up and running and am running some of test scripts in your repo on it now. It's very nice how it stores everything in a database!

If you could add this info to the docs somewhere, I would really appreciate it and it would be very helpful for the package. Thank you for all your help already, I am very excited to look at some GitHub data!