feat: add connection info to command on the CLI#3356
feat: add connection info to command on the CLI#3356izeigerman merged 6 commits intoSQLMesh:mainfrom
Conversation
2ba8ff2 to
0899693
Compare
2370124 to
83867e7
Compare
sqlmesh/core/context.py
Outdated
|
|
||
| def get_sensitive_fields(self) -> Set[str]: | ||
| """Returns a set of common sensitive field names""" | ||
| return { |
There was a problem hiding this comment.
There's already a similar list here: https://github.com/TobikoData/sqlmesh/blob/main/sqlmesh/core/config/scheduler.py#L110-L125. Can we unify them?
There was a problem hiding this comment.
Great idea! Thanks for pointing out!
sqlmesh/core/context.py
Outdated
| strict=strict, | ||
| ) | ||
|
|
||
| def get_sensitive_fields(self) -> Set[str]: |
There was a problem hiding this comment.
Should it be a just a value then?
sqlmesh/core/context.py
Outdated
| "ssh_key", | ||
| } | ||
|
|
||
| def is_sensitive_field(self, field_name: str, sensitive_fields: Set[str]) -> bool: |
There was a problem hiding this comment.
Shouldn't be a method. Let's move this to utils along with the list of sensitive fields.
sqlmesh/core/context.py
Outdated
| field_lower = field_name.lower() | ||
| return any(sensitive in field_lower for sensitive in sensitive_fields) | ||
|
|
||
| def mask_sensitive_value(self, value: Any) -> str: |
sqlmesh/core/context.py
Outdated
| return "*" * len(str(value)) | ||
| return "None" | ||
|
|
||
| def print_config(self, config: ConnectionConfig | None, console: Any) -> None: |
There was a problem hiding this comment.
There's already self available, why pass console as an argument? Also let's make this private (prefix with _). We should be careful about adding public methods to the Context since it's a gateway into SQLMesh Python API.
There was a problem hiding this comment.
Could also be a candidate for utils
There was a problem hiding this comment.
Ok, do you prefer that I create a dedicated utils file for that?
sqlmesh/core/context.py
Outdated
| self.console.log_status_update(f"Models: {len(self.models)}") | ||
| self.console.log_status_update(f"Macros: {len(self._macros) - len(macro.get_registry())}") | ||
|
|
||
| self.console.log_status_update("\n\nConnection:") |
There was a problem hiding this comment.
Should we make the headers more pronounced? Otherwise they blend in with individual connection attributes.
There was a problem hiding this comment.
How would you do that?
There was a problem hiding this comment.
You can make it bold by adding appropriate tags, eg:
self.console.log_status_update("\n\n[bold]Connection:[/bold]")
Ideally we also want to indent everything that follows under the configuration. This way we may not even need to do the highlighting.
Actually, can we just put this into dict and serialize as YAML instead? Eg.:
config = {"Test Connection": { ... }}
338144b to
ac3f868
Compare
ac3f868 to
ae6cf4d
Compare
|
@izeigerman, I moved the code but I didn't make any change yet regarding the template for the info output. |
| @@ -0,0 +1,71 @@ | |||
| from typing import Any, Optional, Set | |||
There was a problem hiding this comment.
Let's call make this module more descriptive by calling it config.py since everything here is related to configuration.
There was a problem hiding this comment.
Alright! I updated the PR.
1592ef7 to
53fb066
Compare
sqlmesh/utils/config.py
Outdated
| console.log_status_update("No connection configuration found.") | ||
| return | ||
|
|
||
| configDict = config.dict(mode="json") |
There was a problem hiding this comment.
| configDict = config.dict(mode="json") | |
| config_dict = config.dict(mode="json") |
sqlmesh/utils/config.py
Outdated
|
|
||
| configDict = config.dict(mode="json") | ||
|
|
||
| for field_name in configDict: |
There was a problem hiding this comment.
| for field_name in configDict: | |
| for field_name in config_dict: |
sqlmesh/utils/config.py
Outdated
| from typing import Any, Optional, Set | ||
|
|
||
| from sqlmesh.core.config.connection import ConnectionConfig | ||
| import yaml |
There was a problem hiding this comment.
from sqlmesh.utils import yaml
16199c0 to
cabfb62
Compare
cabfb62 to
2482c87
Compare
|
Thank you for the review and merge 🎉 |
Description
Adds connection details to help users to ensure that the project is configured as expected.
The output looks like the following: