Skip to content

Commit

Permalink
Merge branch 'main' into task5-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rsgoncalves authored Jun 5, 2024
2 parents da9ddc6 + cfd5733 commit 0786f8a
Show file tree
Hide file tree
Showing 43 changed files with 2,794 additions and 698 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/github_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: GitHub Unit Testing
run-name: Unit Testing on ${{ github.event_name }}

on:
push:
branches: [ "development" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install flake8 pytest wheel
- name: Install text2term
run: |
pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
cd test
python -m unittest simple_tests
45 changes: 45 additions & 0 deletions .github/workflows/upload_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Upload PyPI
run-name: Upload ${{ github.event.release.tag_name }} to PyPI

on:
release:
types: [published]

permissions:
contents: write
id-token: write

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install flake8 twine sdist wheel build
- name: Install text2term
run: |
pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Build dist/
run: |
python -m build --sdist --wheel --no-isolation --outdir dist/ .
- name: Upload to pypi
uses: pypa/gh-action-pypi-publish@release/v1
47 changes: 47 additions & 0 deletions .github/workflows/upload_testpypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Upload Test PyPI
run-name: Upload ${{ github.event.release.tag_name }} to Test PyPI

on:
release:
types: [published]

permissions:
contents: write
id-token: write

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install flake8 twine sdist wheel build
- name: Install text2term
run: |
pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Build dist/
run: |
python -m build --sdist --wheel --no-isolation --outdir dist/ .
- name: Upload to pypi
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ ipython_config.py
# pyenv
.python-version

# For PyPi upload
make-pypi.sh
.pypirc

# Cache should not be uploaded
cache/

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
Expand Down Expand Up @@ -130,5 +137,4 @@ dmypy.json

# Other
.idea
.DS_Store
test/*
.DS_Store
32 changes: 32 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
# golang: "1.19"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: requirements.txt
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 ccb-hms
Copyright (c) 2022 Center for Computational Biomedicine, Harvard Medical School

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
90 changes: 90 additions & 0 deletions README-UI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# ontology-mapper-ui
The following information pertains to the text2term UI, which is written [here](https://github.com/ccb-hms/ontology-mapper-ui) and runs online [here](https://text2term.hms.harvard.edu/). It supports fewer features than the base package does, but provides a user interface for non-programmers.

### Running Locally via Node + Python

##### Requirements

- Node >= 16.0.0
- npm >= 8.0.0
- Python >= 3.9.0
- pip >= 21.0.0
- text2term >= 4.1.2

**\*** These are the versions I have that work; while I know Python 3.9 or higher is necessary, the others may not strictly require the listed versions.

**\*\*** If you are running this locally on Google Chrome, you will likely run into issues with CORS (Cross-Origin Requests) that I have been unable to completely resolve. I would recommend using a different browser, using the Docker method, or finding some way to disable CORS on Chrome while running this.

#### Instructions

##### Initial Setup

When first cloned, run the command:


```
npm install
```

to install all necessary packages for the React frontend.

Next, go into the `flask-api` folder (perhaps by running `cd flask-api`) and run

```
pip install -r requirements-flask.txt
```

to install necessary packages for the Flask api.

##### Running

To run, make sure you are in the root of the repository and run, in two separate command line instances, the command

```
npm start
```

to start the front-end, which can be seen at `localhost:3000`, and the command

```
npm run flask-api
```

to start the back-end, which can be interacted with at `localhost:5000`.

### Running Locally via Docker

#### Requirements

- Docker

#### Instructions

##### Initial Setup

Before running, make sure you have the latest version of the repository built by running the command

```
docker-compose build
```

Docker should build two images:

- `ontology-mapper-api`: the Flask backend API
- `ontology-mapper-client`: the React frontend

##### Running

To run the website, run the command:

```
docker-compose up
```

Docker should build two containers corresponding to the two images.

In a browser, navigate to `localhost:8602` to see the front-end.

### Acknowledgements

Initial setup of React and Flask and Dockerization aided by an [article series](https://blog.miguelgrinberg.com/post/how-to-dockerize-a-react-flask-project) by Miguel Grinberg.
Loading

0 comments on commit 0786f8a

Please sign in to comment.