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
Add upgrade DB to CLI #319
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! I look forward to this.
Can we go ahead and connect a SQL Engine to the database to mint the schemas and go ahead and run stamp on the init as well? I think this should work around the problem.
qcfractal/cli/qcfractal_server.py
Outdated
@@ -226,7 +239,7 @@ def server_start(args, config): | |||
logfile = str(config.base_path / config.fractal.logfile) | |||
|
|||
print("\n>>> Checking the PostgreSQL connection...") | |||
database_name = args.get("database_name", None) or config.database.default_database | |||
database_name = config.database.database_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to create this alias, is it possible just to use it directly below?
qcfractal/config.py
Outdated
@@ -100,6 +102,9 @@ class Config(SettingsCommonConfig): | |||
|
|||
class FractalConfig(ConfigSettings): | |||
|
|||
# class variable, not in the pydantic model | |||
defaults_file_path: ClassVar[str] = os.path.expanduser("~/.qca/qcfractal_defaults.yaml") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other thing to do here is use a _defaults_file_path
. This will tell pydantic to automatically consider it a class var.
if Path(FractalConfig.defaults_file_path).exists(): | ||
with open(FractalConfig.defaults_file_path, "r") as handle: | ||
kwargs['base_folder'] = yaml.load(handle.read(), | ||
Loader=yaml.FullLoader)['default_base_folder'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Not bad.
qcfractal/postgres_harness.py
Outdated
|
||
if ret['retcode'] != 0: | ||
raise ValueError("\nFailed to Upgrade the database, make sure to init the database first before being able to upgrade it.\n") | ||
print(ret) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This print statement will not be executed.
|
||
cmd = [shutil.which('alembic'), | ||
'-c', self._alembic_ini, | ||
'-x', 'uri='+self.config.database_uri(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use a f-string here to match other areas?
|
||
ret = self._run([shutil.which('alembic'), | ||
'-c', self._alembic_ini, | ||
'-x', 'uri='+self.config.database_uri(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto on f-string.
@@ -315,7 +315,6 @@ def start(self, timeout: int = 5) -> None: | |||
self._qcfractal_proc = _background_process([ | |||
shutil.which("qcfractal-server"), | |||
"start", | |||
f"--database-name={self._dbname}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will create some restart issues. I think we will need to init a new temporary folder and qcfractal-init
into that every time.
This pull request introduces 5 alerts when merging 01111a8 into e96ff16 - view on LGTM.com new alerts:
|
This pull request introduces 3 alerts when merging 2549ae3 into ea58476 - view on LGTM.com new alerts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Ready to merge?
Yes, ready to merge. |
Description
Added alembic migrations to the CLI using the command
qcfractal-server upgrade
.TODO:
[x] Add testing
Status