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

[rest] Adding SKEMA_GRAPH_DB_HOST and SKEMA_GRAPH_DB_PORT environment variables #650

Merged
merged 8 commits into from
Nov 15, 2023

Conversation

vincentraymond-ua
Copy link
Contributor

@vincentraymond-ua vincentraymond-ua commented Nov 15, 2023

Adding environmental variables

Adds the SKEMA_GRAPH_DB_HOST and SKEMA_GRAPH_DB_PORT environmental variables to skema/rest.

Updates the execution engine to use these values to connect to Memgraph.

See the corresponding PR to set these values in the ASKEM-TA1-DockerVM repo:
ml4ai/ASKEM-TA1-DockerVM#44

@vincentraymond-ua vincentraymond-ua changed the title Vraymond/morae updates [rest] Adding SKEMA_GRAPH_DB_HOST and SKEMA_GRAPH_DB_PORT environment variables Nov 15, 2023
@vincentraymond-ua vincentraymond-ua marked this pull request as ready for review November 15, 2023 19:08
Copy link
Collaborator

@Free-Quarks Free-Quarks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Collaborator

@myedibleenso myedibleenso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vincentraymond-ua , this is a great start, but we will also need to modify how the skema-rs REST API receives this information:

/// Database host
#[arg(long, default_value_t = String::from("localhost"))]
db_host: String,

It seems it uses as assumed port.

@Free-Quarks
Copy link
Collaborator

Free-Quarks commented Nov 15, 2023

The information is passed as a command line argument on the docker side entrypoint for the RUST service. So this should still work for both services, since the environment variable is also set on the docker side.

@myedibleenso
Copy link
Collaborator

myedibleenso commented Nov 15, 2023

The information is passed as a command line argument on the docker side entrypoint for RUST service. So this should still work for both services, since the environment variable is also set on the docker side.

@Free-Quarks, can you explain what happens today if you're using something other than the default DB port (ex. a proxied request)?

@Free-Quarks
Copy link
Collaborator

Free-Quarks commented Nov 15, 2023

I agree it should be an environment variable and is a left over way of doing things before we dockerized everything

@myedibleenso
Copy link
Collaborator

If I'm reading the Rust code correctly (big if), if you include the port in your value for db_host it will be used by execute_query:

pub fn execute_query(query: &str, host: &str) -> Result<(), MgError> {
// Connect to Memgraph.
let connect_params = ConnectParams {
host: Some(host.to_string()),
..Default::default()
};

Is that correct, @Free-Quarks ?

@myedibleenso
Copy link
Collaborator

Actually, I take that back. I think a port is assumed: https://docs.rs/rsmgclient/latest/rsmgclient/struct.ConnectParams.html

Could we at least optionally specify the db port in the skema-rs runnable with the standard bolt-like default?

@myedibleenso
Copy link
Collaborator

let connect_params = ConnectParams { 
         host: Some(host.to_string()), 
         port: Some(port.to_int()),
         ..Default::default() 
     }; 

... and:

#[derive(Debug)]
   pub struct Config {
      pub db_host: String,
      // FIXME: how to set a default (ex. 7687) here?
      pub db_port: int
   }

@myedibleenso
Copy link
Collaborator

^ idk if my Rust is correct (probably not), but hopefully it at least conveys the idea.

@Free-Quarks
Copy link
Collaborator

Yeah I think I get what you are saying. (looping in @adarshp to double check as he wrote the code) We have it setup to get the port from the command line argument, but when we hit Memgraph we don't specify it each time and assume it is static, but we could specify it in the way you are showing. I could add that to this PR.

@myedibleenso
Copy link
Collaborator

myedibleenso commented Nov 15, 2023

I see use of host in a bunch of places, so probably doing this would involve touching many lines of code...

@myedibleenso
Copy link
Collaborator

myedibleenso commented Nov 15, 2023

I will deal with it on the deployment side and drop pushing for a change for now...

Copy link
Collaborator

@myedibleenso myedibleenso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that a DB port cannot currently be passed on the Rust side.

@myedibleenso
Copy link
Collaborator

@vincentraymond-ua , do you these env variables need to be noted in our documentation, or is it sufficient to update the dockerVM repo?

@vincentraymond-ua
Copy link
Contributor Author

@myedibleenso - Thats a good question, it may be valuable to have these described in the documentation, perhaps in the dev environment page: https://ml4ai.github.io/skema/dev/env/

@vincentraymond-ua vincentraymond-ua merged commit d5aecfd into main Nov 15, 2023
8 checks passed
@vincentraymond-ua vincentraymond-ua deleted the vraymond/morae_updates branch November 15, 2023 21:20
github-actions bot added a commit that referenced this pull request Nov 15, 2023
… variables (#650)

## Adding environmental variables
Adds the `SKEMA_GRAPH_DB_HOST` and `SKEMA_GRAPH_DB_PORT` environmental
variables to skema/rest.

Updates the execution engine to use these values to connect to Memgraph.

See the corresponding PR to set these values in the ASKEM-TA1-DockerVM
repo:
ml4ai/ASKEM-TA1-DockerVM#44

---------

Co-authored-by: Justin <[email protected]>
Co-authored-by: Gus Hahn-Powell <[email protected]> d5aecfd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants