Skip to content

Commit

Permalink
Issue #68: Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois-Werbrouck committed Jul 17, 2024
1 parent 234b57b commit a0b9ffa
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 22 deletions.
2 changes: 1 addition & 1 deletion datastore/FertiScan/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from dotenv import load_dotenv

import uuid

load_dotenv()

Expand Down
4 changes: 2 additions & 2 deletions datastore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def new_user(cursor, email, connection_string, tier="user") -> User:


async def get_user_container_client(
user_id, tier="user", storage_url=NACHET_STORAGE_URL
user_id, storage_url, account, key, tier="user"
):
"""
Get the container client of a user
Expand All @@ -123,7 +123,7 @@ async def get_user_container_client(
Returns: ContainerClient object
"""
sas = blob.get_account_sas(NACHET_BLOB_ACCOUNT, NACHET_BLOB_KEY)
sas = blob.get_account_sas(account, key)
# Get the container client
container_client = await azure_storage.mount_container(
storage_url, user_id, True, tier, sas
Expand Down
24 changes: 7 additions & 17 deletions datastore/db/__init__.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
"""
This module contains the function interacting with the database directly.
"""
import os

import psycopg
from dotenv import load_dotenv

load_dotenv()

# def connect_db():
# """Connect to the postgresql database and return the connection."""
# connection = psycopg.connect(
# conninfo=NACHET_DB_URL,
# autocommit=False,
# options=f"-c search_path={NACHET_SCHEMA},public")
# assert connection.info.encoding == 'utf-8', (
# 'Encoding is not UTF8: ' + connection.info.encoding)
# # psycopg.extras.register_uuid()
# return connection


def connect_db(conn_str : str = NACHET_DB_URL, schema :str = NACHET_SCHEMA):
def connect_db(conn_str: str, schema: str):
"""Connect to the postgresql database and return the connection."""
connection = psycopg.connect(
conninfo=conn_str,
Expand All @@ -45,14 +34,15 @@ def end_query(connection, cursor):
connection.close()


def create_search_path(connection, cur,schema = NACHET_SCHEMA):
def create_search_path(connection, cur, schema):
cur.execute(f"""SET search_path TO "{schema}";""")
connection.commit()


if __name__ == "__main__":
connection = connect_db(FERTISCAN_DB_URL,FERTISCAN_SCHEMA)
print(FERTISCAN_DB_URL)
connection = connect_db("test", "test")
print("test")
cur = cursor(connection)
create_search_path(connection, cur,FERTISCAN_SCHEMA)
create_search_path(connection, cur, "test")
end_query(connection, cur)
print("Connection to the database successful")
3 changes: 2 additions & 1 deletion doc/datastore.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ flowchart LR;
```

## Database Architecture

For more detail on each app database architecture go check [Nachet Architecture](nachetArchitecture.md) and [Fertiscan Architecture](FertiscanArchitecture.md).

Check failure on line 72 in doc/datastore.md

View workflow job for this annotation

GitHub Actions / workflow-markdown-check / markdown-check

Line length

doc/datastore.md:72:81 MD013/line-length Line length [Expected: 80; Actual: 161] https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md013.md

### Global Needs

- A User must be able to take a picture on the app and it must be saved in the
Expand All @@ -78,4 +80,3 @@ flowchart LR;

- A User can verify the result of a picture that went through the pipeline and
the changes are saved for training.

2 changes: 1 addition & 1 deletion doc/metadata-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ process is complete, the upload process will come into play, enabling the
distribution of the files between the BLOB storage and a PostgreSQL database.

We are currently improving the process to make it more efficient across all our
project.
project.

``` mermaid
Expand Down

0 comments on commit a0b9ffa

Please sign in to comment.