This README will get you started and guide you through the project
Photo contest API is an API for the Runtime Revolution photo contest that takes place every month and aims to allow a fair and easy voting for all participants.
- PHOTO CONTEST API 📸
If you have this one already, you can jump to the next section (Configuration - Setting your python version).
-
Now that you have pyenv, install the version we want to use:
pyenv install -v 3.10.4
-
Check your list for the installed python version:
ls ~/.pyenv/versions/
or by using
pyenv versions
To use poetry, we will need to have python 3.5 or greater.
-
Now let's start by always activating a virtual environment to work on when we open the project: If you need to get out of this virtual environment just type deactivate
poetry shell
-
You should have a file called pyproject.toml, with it we can install everything that is needed! Just a second, make sure you are on your project folder! Let's go and install everything now:
poetry install
This is great! Right now, we have our packages installed!
-
One last thing! We still need to tell our IDE to use this new interpreter! Alright, and how do we do this? Its easy, really. (This next steps will be for vscode)
-
Copy the path from the command below:
poetry env info --path
-
In your vscode, go to settings and search for python interpreter
-
Now select to use a specific path and use the one you just copied Press Enter and you'r done! Now vscode will use this one.
-
Now, how can we run the app?
To start the docker container run
make up
After that run the migrations if needed
make migrate
Finally run the app
make run
Perfect! You are now running the project locally and you can now start coding!
To run the tests, inside your working environment run:
make test
To add tests remember that the python automatic discover only works properly for files named "test_*.py".
If you want to use the vscode debugger for a particular test you can use the launch.json.example, rename it launch.json and place it in the .vscode folder in the root of your working directory.
To generate dummy data ensure that the localstack is running and all the migrations are aplied and use the command:
make populate
This command should only be used when the database is empty or it will probaly raise integraty errors related to duplicate primary keys.
Check what's available in the Makefile.
Python 3.10.13 environment must exist and be active. Use poetry shell for this.
make up
make migrate
make run
After you have installed Docker we will need to install AWS CLI. Even though we are simulating the AWS, we will require this to comunicate with the docker containers:
- Install AWS CLI
- After it is installed we will need to supply credentials, even if the
credentials are dummies. Localstack requires this details to be present. For that run the command:
aws configure
In order to create a bucket you can just run the tests to verify everithing is working properly and it will be created automatically.
Well, hello there! If you are looking for automation, you have come to the right place!
Looking for a way to start your venv by doing... nothing!? I know i know, it looks almost like magic. Let me tell you about direnv
-
direnv will load and unload a virtual environment everytime we enter or leave the folder How do we install it? Let's take a look.
-
Let's start by creating an empty file called .envrc
-
Now we can download direnv here
-
Hook it into your shell like this
-
Alright and finally add the following to your .envrc:
layout pyenv 3.10.4
Note: Everytime you edit your .envrc file direnv will ask you to give permission by typing:direnv allow
-
Important: Now that you changed for direnv replicate the python interpreter change that you did in poetry section
-
Reload your shell and you'r set! Now you can leave your folder and come back inside to test if .direnv will show up (thats your new venv). Everytime you go into or out of your project folder .direnv will activate or deactivate!
-
Everytime we need to work on a new feature, bug or any type of task, we need to create a new branch. Below will be a step by step guide on how we can create and start to work on a task:
The nomenclature for someone named "João Gomes" that need to fix a new "Bug" on a ticket with the ID "1234" and name "Update salary" goes like this:
jg/bug/1234/Update-salary
-
jg - First and last name initials
-
bug - Type of task to be performed
-
1234 - Ticket ID
-
Update-salary - Ticket name
- You can always talk to your Team Leader or the repo owner for any question regarding this project.
The data model for this project is as follows:
classDiagram
User <|-- Collection
User <|-- Picture
PictureComment <|-- Picture
Contest <|-- Picture
Contest <|-- ContestSubmission
Contest <|-- User
ContestSubmission <|-- User
PictureComment <|-- User
Collection <|-- Picture
ContestSubmission <|-- Picture
class User{
+String email
+String name_first
+String name_last
+Picture profile_picture
+DateTime profile_picture_updated_at
+String user_handle
}
class Picture{
+User User
+String file
+User likes
}
class PictureComment{
+User user
+Picture picture
+String text
+DateTime created_at
}
class Collection{
+String name
+User user
+Picture pictures
}
class Contest{
+String title
+String description
+Picture cover_picture
+String prize
+Boolean automated_dates
+DateTime upload_phase_start
+DateTime upload_phase_end
+DateTime voting_phase_end
+User winners
+User created_by
}
class ContestSubmission{
+Contest contest
+Picture picture
+DateTime submission_date
+User votes
}
When experiencing an error such as the one below:
OSError: dlopen(/usr/local/lib/libgdal.dylib, 0x0006): Symbol not found: __ZN3Aws6Client19ClientConfigurationC1Ev
Referenced from: <94E9B77D-69B0-39FF-BF05-8494E3AB846D> /usr/local/Cellar/apache-arrow/12.0.1_4/lib/libarrow.1200.1.0.dylib
Expected in: <D3694CDE-733E-33BE-9C47-F7B918E1764B> /usr/local/Cellar/aws-sdk-cpp/1.11.145/lib/libaws-cpp-sdk-core.dylib
The solution considers you are using Rosetta in your terminal
Try to reinstall gdal.
- Check it is installed
brew list
- Remove it
brew remove gdal
- Install it
brew install gdal