Skip to content

Commit 8daf4a0

Browse files
AnHoffedudsan
andcommitted
Adding docker, automated documentation and more
Co-authored-by: edudsan <eduschusan@gmail.com>
1 parent 790415c commit 8daf4a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3491
-46
lines changed

.github/workflows/ci.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Project CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
- uses: actions/checkout@v3
18+
19+
- name: Build the Docker image
20+
run: docker build ./CoCa_pytorch --file ./CoCa_pytorch/Dockerfile.app --tag my-image-name:$(date +%s)
21+
22+
- name: Build Documentation
23+
run: sphinx-build -b html source/ _build
24+
25+
- name: Run Tests
26+
run: pytest --cov
27+
28+
- name: Poetry Build
29+
run: |
30+
poetry build
31+
poetry publish
32+
33+
lint:
34+
name: Lint
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v3
40+
41+
- name: Set up Python
42+
uses: actions/setup-python@v2
43+
with:
44+
python-version: 3.x
45+
46+
- name: Install dependencies
47+
run: pip install -r requirements.txt
48+
49+
- name: Run linting
50+
run: pylint src/main.py

.github/workflows/python-publish.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

Dockerfile.app

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM python:3.7
2+
3+
WORKDIR /src
4+
5+
COPY ../requirements.txt .
6+
7+
RUN pip install --upgrade pip
8+
RUN pip install -r requirements.txt
9+
10+
COPY . .
11+
12+
CMD ["python","main.py"]

Dockerfile.db

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM mysql:latest
2+
3+
ENV MYSQL_ROOT_PASSWORD=password
4+
ENV MYSQL_DATABASE=coca_db
5+
ENV MYSQL_USER=coca_user
6+
ENV MYSQL_PASSWORD=coca_password
7+
8+
EXPOSE 3306

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

README.md

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<img src="./coca.png" width="450px"></img>
1+
<img src="./assets/coca.png" width="650px"></img>
22

33
## CoCa - Pytorch
44

@@ -9,18 +9,56 @@ This repository also chooses to adopt the specific transformer architecture from
99
## Install
1010

1111
```bash
12-
$ pip install coca-pytorch
12+
$ python -m venv env
13+
$ source env/bin/activate
14+
$ pip install -r requirements.txt
15+
$ poetry build
1316
```
1417

15-
## Usage
18+
PS: to see the documentation, insert the following command and open [index.html](_build/index.html) in your browser:
19+
20+
```bash
21+
$ sphinx-build -b html source/ _build
22+
```
23+
24+
## Publish
25+
26+
This step is optional and will only work if the repository is public. Other information, as how to publish to a private repository, may be found in [Poetry documentation](https://python-poetry.org/docs/libraries/).
27+
28+
```bash
29+
$ poetry build
30+
$ poetry publish -r my-repository
31+
```
32+
33+
## Docker Image
1634

17-
First install the `vit-pytorch` for the image encoder, which needs to be pretrained
35+
There are two containers for this project. One is for the database (it's not created yet, but it already has a Dockerfile prepared) and one for the application. The docker-compose.yml archive is responsible for relating both.
36+
37+
To build the images, you need to have Docker installed and running in your machine. Then, use the following command:
38+
39+
```bash
40+
$ docker-compose up -d
41+
```
42+
43+
You can also run each container separatelly. Just run:
1844

1945
```bash
20-
$ pip install vit-pytorch>=0.40.2
46+
# Create database container
47+
docker build -t db-container -f db/Dockerfile db/
48+
49+
# Execute database container
50+
docker run -d --name mysql-container -p 3306:3306 db-container
51+
52+
# Create app container
53+
docker build -t app-container -f app/Dockerfile app/
54+
55+
# Execute app container linked to the database container
56+
docker run -d --name coca-app-container --link mysql-container:mysql app-container
2157
```
2258

23-
Then
59+
## Usage
60+
61+
First install the `vit-pytorch` (included in [requirements.txt](requirements.txt)) for the image encoder, which needs to be pretrained. Then:
2462

2563
```python
2664
import torch

_build/.buildinfo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Sphinx build info version 1
2+
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3+
config: 9a2c7d810f158951a71e77e6a6da3d46
4+
tags: 645f666f9bcd5a90fca523b33c5a78b7
17.7 KB
Binary file not shown.

_build/.doctrees/index.doctree

4.87 KB
Binary file not shown.

_build/_sources/index.rst.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. CoCa-pytorch documentation master file, created by
2+
sphinx-quickstart on Mon Jun 26 14:19:03 2023.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to CoCa-pytorch's documentation!
7+
========================================
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
:caption: Contents:
12+
13+
14+
15+
Indices and tables
16+
==================
17+
18+
* :ref:`genindex`
19+
* :ref:`modindex`
20+
* :ref:`search`

0 commit comments

Comments
 (0)