Skip to content
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

issue #80: remove louis reference from pyproject.toml #89

Merged
merged 9 commits into from
Apr 2, 2024

Conversation

k-allagbe
Copy link
Member

Closes #80: pyproject.toml referencing louis

@k-allagbe k-allagbe requested a review from a team as a code owner March 26, 2024 17:19
@k-allagbe k-allagbe linked an issue Mar 26, 2024 that may be closed by this pull request
2 tasks
@k-allagbe k-allagbe self-assigned this Mar 26, 2024
@k-allagbe k-allagbe changed the title issue #80: remove louis reference issue #80: remove louis reference from pyproject.toml Mar 26, 2024
@k-allagbe k-allagbe marked this pull request as draft March 26, 2024 17:36
@k-allagbe
Copy link
Member Author

k-allagbe commented Mar 26, 2024

Reported the test failure issue here #90

@k-allagbe k-allagbe marked this pull request as ready for review March 26, 2024 18:19
@k-allagbe k-allagbe marked this pull request as draft March 27, 2024 09:06
@k-allagbe k-allagbe force-pushed the 80-fix-package-setup-referencing-louis branch from d8a9362 to 1d19d59 Compare March 27, 2024 09:07
@k-allagbe k-allagbe force-pushed the 80-fix-package-setup-referencing-louis branch from 1d19d59 to cf88406 Compare March 27, 2024 10:27
@k-allagbe k-allagbe marked this pull request as ready for review March 27, 2024 12:04
Comment on lines +11 to +12
api_key=os.environ["OPENAI_API_KEY"],
azure_endpoint=f"https://{os.environ['AZURE_OPENAI_SERVICE']}.openai.azure.com",
Copy link
Member

@ThomasCardin ThomasCardin Mar 27, 2024

Choose a reason for hiding this comment

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

This is a personal preference, but I find defining environment variables has a constant is very helpful for change management. Here's an example:

OPENAI_API_KEY = 'OPENAI_API_KEY'
AZURE_OPENAI_SERVICE = 'AZURE_OPENAI_SERVICE'

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. I would suggest a good round of refactoring on this codebase, especially since the delay issues have been fixed to a tolerable amount.


# https://learn.microsoft.com/en-us/azure/cognitive-services/openai/how-to/embeddings?tabs=python


def safe_get(key):
value = os.environ.get(key)
if not value:
raise Exception(f"Environment variable {key} not defined")

Choose a reason for hiding this comment

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

I suggest the use of KeyError or a custom exception instead of Exception to be more precise on the nature of the exception.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. I would suggest a round of refactor. #92

@@ -33,7 +29,6 @@ def raise_error(message):

def connect_db():
"""Connect to the postgresql database and return the connection."""
logger.info(f"Connecting to {LOUIS_DSN}")
connection = psycopg.connect(
conninfo=LOUIS_DSN,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we change the secrets from [LOUIS_...] to [AI_LAB_...] if we want to remove all references?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I would suggest to rewrite packages in a way that they don't force the env var naming on their users because it could lead to conflicts. For instance, if I already had POSTGRES_URI in my repo, ailab-db would force me to rename it to LOUIS_DSN or have a duplicate of the same value. What I suggest is to pass the value to the function that needs it.

Fixing this would even greatly improve testability. I suggest this be part of #92.

@k-allagbe k-allagbe merged commit 627a7ec into main Apr 2, 2024
4 of 5 checks passed
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.

pyproject.toml references non-existent directory louis
5 participants