Closed waleedkadous closed 7 months ago
Assalamu alaikum brother M Waleed,
JazakAllahu Khairan for your work! May Allah SWT accept it.
I'd like to contribute to adding continuous integration. Here's my understanding of the issue and a proposed plan:
Proposed Plan:
Write Pytest Tests:
Update Workflow (".github/workflows/python-app.yml"):
Questions:
I'm ready to start implementing this plan!
Wa alaikum assalam Br Abdullah! May Allah reward you for going through the source code and understanding exactly what needs to be done.
Yes, it does integrate with my vision -- it's like you read my mind. You've covered the two types of testing I was hoping would be covered: normal CI testing, and answer quality testing.
Perhaps most important is testing to ensure the API implements permissions correctly: e.g. ensuring that a particular thread is only accessible to the person who created the thread.
I've begun addressing this issue. As a first step, I successfully ran Ansari locally and documented the necessary setup process. These instructions could be incorporated into a contribution guide or the README. I'm happy to collaborate on integrating them into the project's documentation!
Next Steps:
I'd appreciate your thoughts on these proposed tests.
Ansari
LocallyPrerequisites
Environment Setup
Export API Keys: Set the following environment variables, replacing placeholders:
export OPENAI_API_KEY="your_openai_api_key"
export LANGFUSE_SECRET_KEY="your_langfuse_secret_key"
export LANGFUSE_PUBLIC_KEY="your_langfuse_public_key"
export KALEMAT_API_KEY="kalimat_visitor_api_key"
PostgreSQL Database (Ubuntu) Install, start, and configure.
Install PostgreSQL:
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
Start PostgreSQL Service:
sudo systemctl start postgresql
Create User and Database:
sudo su - postgres
createuser mwk # mwk stands for: "Mohammed Waleed Kadous" :)
psql -c "ALTER USER mwk WITH PASSWORD 'pw';"
createdb -O mwk mwk
exit
Set PostgreSQL Password:
export PGPASSWORD="pw"
Configure Authentication:
sudo -u postgres psql # Switch to the 'postgres' user to access the database
GRANT ALL PRIVILEGES ON DATABASE mwk TO mwk; # Grant necessary permissions
SHOW hba_file; # Find the location of the pg_hba.conf file
sudo gedit /path/to/pg_hba.conf # Edit the configuration file (replace '/path/to/pg_hba.conf' with the actual path)
# In the file, find the line: local all all peer
# Change 'peer' to 'md5', save and exit
sudo systemctl restart postgresql # Restart PostgreSQL for changes to take effect
Explanation:
pg_hba.conf
and changing 'peer' to 'md5' enforces password-based authentication, enhancing security.Create Tables:
sudo -u postgres psql
\i ./sql/01_create_tables.sql
\i ./sql/02_create_user_tokens.sql
\i ./sql/03_create_reset_tokens.sql
\i ./sql/04_create_feedback_table.sql
Running the Application
Start Backend Server:
gunicorn -w 2 -k uvicorn.workers.UvicornWorker main_api:app
Execute Exercise Script:
python api_v2_exercise.py local
Thank you for all your hard work, Abdullah. Marking this as closed.
Difficulty: Medium Est time: 20 hours
At the moment, we do not have continuous integration. As a result, we sometimes ship versions of Ansari that may have issues. The goal is to add continuous integration to: