-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: Firestore stag db config #6
feat: Firestore stag db config #6
Conversation
META-36 Connect Firestore database to Sourcing Repo(s)
Just figured that one of your tickets was a duplicate, therefore adding a new one as otherwise your workload wouldn't match ours this week :) Basically the same task of connecting firebase as for the analytics repo, but for at least 1 sourcing repo! Mostly reusing the same logic as in the |
☂️ Python Coverage
Overall Coverage
New Files
Modified FilesNo covered modified files...
|
This is the same as here right? |
yes the task is similar. We need the db connection in both repos. |
Does this give "selective" access to the database? I.e., only the part that is relevant for the Github module, so we can't interfere with other modules writing to the db? Also, I would need the secrets to test. |
Will update you after team meet and secrets are sent. |
Yes, that would also be a requirement before merging this! |
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.
Same comments as here
parma_db/firestore_db.py
Outdated
import firebase_admin | ||
import os | ||
from firebase_admin import credentials | ||
from firebase_admin import firestore |
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.
Looks like these imports are little bit mixed.
Also I couldn't find a package for firebase_admin and firebase-admin using micromamba. But after activating the micromamba environment, I was able to use pip
command which is for the activated environment
(parma-mining-github) egekocabas@Eges-Air parma-mining-github % which pip
/Users/egekocabas/micromamba/envs/parma-mining-github/bin/pip
(parma-mining-github) egekocabas@Eges-Air parma-mining-github %
GitHub firebase-admin here
Firebase setup here
It seems that we need to use pip to install this dependency. If its the case then it should be added into the README.md
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 caught on my eye.
I think in here we should add below line into Makefile
--> install
pip install firebase-admin
then I worked for me 👌🏻
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 pip install needs to be added to Makefile
and also in Dockerfile
@saiyam3243 How's the status here? As this is still a task from last week I'd like to see this finished as soon as possible! As It's only ~80 lines of code , I think this shouldn't be too hard to finish in time. Please let us know if you can foreseeably not finish all the tasks assigned to you so we can reallocate our resources accordingly! |
@saiyam3243 @robinholzi Would be great if we can merge this soon. Not being able to use the db is starting to be a blocker for us. |
@Constantin343 I see that this topic is quite important for you, that's why we already started it in a sprint of Nov. 20th. I hope that you/your team (@Constantin343) and @saiyam3243 have finished the schema specifications by now. (meta linear task) |
Hi @Constantin343, I am waiting for your response on slack since two days on the topic of firestore db schema, my implementation is ready but I am just waiting if you need any changes there, if you think my proposed schema is fine, I can push my changes. I have already pushed my code in analytics team and the code will look similar but with few changes. |
@saiyam3243 sorry, somehow I didn't get notified by Slack and therefore did not give you feedback on the schema. Do you need something else from data sourcing to proceed? |
@Constantin343 @saiyam3243 Ping me on Slack once you resolve the unclear points! |
@saiyam3243 How is the access handeled now? I saw that I can define the datasource as a string to write to a collection (e.g., function add_new_raw_data), which looks like we can access all collections from every data source or is there already some mechanism in place to restrict the access? |
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.
I left some comments 👌🏻 but before starting, it is better to update this branch first (merge from main to your branch)
parma_db/firestore_db.py
Outdated
import firebase_admin | ||
import os | ||
from firebase_admin import credentials | ||
from firebase_admin import firestore |
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 pip install needs to be added to Makefile
and also in Dockerfile
.collection(page_id) | ||
.document("raw_data") | ||
) | ||
doc_ref.set(raw_data_content) |
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.
So that would mean we overwrite the old raw_data or how would it work? I think we need a way to ensure we don't do that, maybe we can add a new document with the timestamp every time we write raw data.
It is important for the client that we collect the data over time
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.
Yes, as I mentioned in the last comment, we can add time stamp and last _modified_page fields to the pages document to avoid raw_data to get overwritten!
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.
But why is page_id a string here and not a dict as before? That seems to be a bit inconsistent
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.
thats a mistake. changed now!
Any updates regarding this topic? |
When using the Firebase Admin SDK, security rules do not apply because it assumes you have administrative privileges. To restrict access on the server side, we need to implement our logic like defining a list of authenticated users for a particular data source and checking their access every time! |
I found out a way. Within firestore db rules, we can specify the rights of the user/devs, in that way we can save db to get accessed by anyone |
fyi. For that, we need also need to authenticate first and have "service accounts" within the firebase auth service. I will build something for that as currently there's nothing in place as far as I can see. |
This solution uses the |
Motivation
For the integration of firestore db with this repo
Changes
Integration of firestore in repo and passed env variables via ci.yml
Checklist
!
(e.g.feat!: Update endpoint
)