Skip to content

Feature 267 db engine - #270

Merged
deniztepe merged 18 commits into
developfrom
feature-267-db-engine
Jun 27, 2022
Merged

Feature 267 db engine#270
deniztepe merged 18 commits into
developfrom
feature-267-db-engine

Conversation

@FlorianK13

Copy link
Copy Markdown
Member

Created an engine parameter at Mastr init(). This parameter decides which database is used.

FlorianK13 and others added 14 commits June 14, 2022 09:34
With this commit the bulk download works by only using the
self._engine parameter. However the API still needs to be adapted.
This needs to be done if we want the docker-compose file
to be part of the python package.
Additionally, the setup_docker function was moved to a helpers module.
We need it in the open_mastr folder if it shall be part of the
python package.
In the usual workflow, the engine is created at initialization of a
Mastr object. This engine then needs to be passed to the MastrMirror
object from the soap API.
* The references contains information about engine parameter
* Configuratin description adapted
* Black applied on helpers
* TODO: Describe docker-postgres, once it works
* TODO: Update changelog
@FlorianK13
FlorianK13 marked this pull request as draft June 22, 2022 10:45
@FlorianK13
FlorianK13 requested a review from chrwm June 22, 2022 12:55
@FlorianK13
FlorianK13 marked this pull request as ready for review June 23, 2022 06:06
Comment thread docs/getting_started.rst Outdated
When using `download(method="API")`, the data is retrieved from the MaStR API. For using the MaStR API,
credentials are needed (see :ref:`Get data via the MaStR-API`). By using the API,
additional parameters can be set to define in detail which data should be reveived.
additional parameters can be set to define in detail which data should be reviewed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
additional parameters can be set to define in detail which data should be reviewed.
additional parameters can be set to define in detail which data should be obtained.

Comment thread docs/getting_started.rst Outdated
Comment thread open_mastr/mastr.py
@@ -1,10 +1,8 @@
from datetime import date, datetime
from datetime import date

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Clear commit message that fits changes, nice and easy to review!

Comment on lines +67 to 76
def validate_parameter_format_for_mastr_init(engine) -> None:
if engine not in ["sqlite", "docker-postgres"]:
if not isinstance(engine, sqlalchemy.engine.Engine):
raise ValueError(
"parameter engine has to be either 'sqlite' "
"or 'docker-postgres' or an sqlalchemy.engine.Engine object."
)


def validate_parameter_format_for_download_method(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks fine!

Comment thread tests/test_helpers.py
Comment on lines +194 to +197

for engine in engine_list_failing:
with pytest.raises(ValueError):
validate_parameter_format_for_mastr_init(engine)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this implementation resulting in a test failure for all other values apart from ["sqlite", "docker-postgres", db._engine] and not only a failure for ["HI", 12] ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, but it is hard to test for such a large amount of failing values, so I just chose an exemplary string and integer value that makes the code fail.

Comment thread docs/advanced.rst
Comment on lines +57 to +61

* slqite: This database will be stored in `$HOME/.open-MaStR/data/sqlite`.
* docker-postgres: A docker container of a PostgreSQL database.
* own database: The Mastr class accepts a sqlalchemy.engine.Engine object as engine which provides the user to
use any other desired database.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding this!

Co-authored-by: chrwm <54852694+chrwm@users.noreply.github.com>
@FlorianK13

Copy link
Copy Markdown
Member Author

@chrwm Can we merge the branch now? Because Deniz and me want to do a restructuring session later today and it would be best if this branch is already merged then.

@FlorianK13
FlorianK13 requested a review from deniztepe June 27, 2022 08:13

@deniztepe deniztepe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Checked

@deniztepe
deniztepe merged commit f27c51c into develop Jun 27, 2022
@deniztepe
deniztepe deleted the feature-267-db-engine branch June 27, 2022 08:15
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

Successfully merging this pull request may close these issues.

3 participants