Skip to content

Pull database logic out of core.py and transaction.py #62

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

Merged
merged 34 commits into from
Mar 19, 2022
Merged

Conversation

jonhealy1
Copy link
Collaborator

Related Issue(s):

Description:
Pull db logic out of core and transaction.py to make codebase more modular.

PR Checklist:

  • Code is formatted and linted (run pre-commit run --all-files)
  • Tests pass (run make test)
  • Documentation has been updated to reflect changes, if applicable, and docs build successfully (run make docs)
  • Changes are added to the changelog

@jonhealy1 jonhealy1 requested a review from philvarner March 18, 2022 11:49
@@ -8,7 +8,6 @@ services:
build:
context: .
dockerfile: Dockerfile
platform: linux/amd64
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My linux laptop doesn't like this line?

Copy link
Collaborator

Choose a reason for hiding this comment

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

interesting, i'm running on macos so probably why i didn't see it

@jonhealy1 jonhealy1 requested a review from gadomski March 18, 2022 12:37
@jonhealy1
Copy link
Collaborator Author

I've only moved the db logic out of core.py so far

@@ -51,23 +41,14 @@ class CoreCrudClient(BaseCoreClient):
)
settings = ElasticsearchSettings()
client = settings.create_client
database = CoreDatabaseLogic()
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this database attribute completely abstracts away access to the client and settings, is that correct? If so, the client and settings attributes should be removed.

Also, is there any reason not to just call it Database instead of CoreDatabaseLogic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True - good catch. I was going to have a TransactionsDatabaseLogic but it could all be one class or have a better name too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 for just having one class for both.

perhaps DatabaseClient? I assume the longer-term goal here is to have ElasticsearchDatabaseClient and OpensearchDatabaseClient, that abstract away the small differences between the two.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I could also have a MongoClient outside of the repo that I could maybe inject when I wanted to and not have to keep a full fast-stac-api backend up to date.

Comment on lines +52 to +53
except elasticsearch.exceptions.NotFoundError:
raise NotFoundError("No collections exist")
Copy link
Member

Choose a reason for hiding this comment

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

Should this return an empty Collections instead of raising?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True, that would make sense. I would have to ask @philvarner maybe.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, an empty Collections rather than 404

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe file an issue and put that in a separate PR instead of this one -- just focus on the reorganization here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok for sure

@philvarner
Copy link
Collaborator

@jonhealy1 what's your ETA on having this ready to merge? since it's blocking any other work being done because it moves so much code around

@jonhealy1
Copy link
Collaborator Author

@jonhealy1 what's your ETA on having this ready to merge? since it's blocking any other work being done because it moves so much code around

I can finish tomorrow - I'm in Turkey so it's 12:06 am here right now. Or we could merge this and make a pr to do the transactions code later if you think?

@jonhealy1 jonhealy1 marked this pull request as ready for review March 18, 2022 21:19
@jonhealy1
Copy link
Collaborator Author

@philvarner sorry for blocking you - this should be ready now

@jonhealy1 jonhealy1 requested a review from gadomski March 19, 2022 08:08
@jonhealy1
Copy link
Collaborator Author

Just some final cleaning .... and a ridiculous ci error

@philvarner
Copy link
Collaborator

@philvarner sorry for blocking you - this should be ready now

no worries, thanks for getting this done so quickly!

@jonhealy1 jonhealy1 merged commit 363e2cc into main Mar 19, 2022
@jonhealy1 jonhealy1 deleted the modular_db branch March 21, 2022 19:36
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