Giter VIP home page Giter VIP logo

pyapi's Introduction

ClassTranscribe Python API

Powered by Flask + Connexion + SQLAlchemy

License

Please see the open-source License.

Build Status

Branch Status
Production Production
Staging Staging
Experiment Experiment

Configuration

Environment variables can be used to set the configuration.

Application Config

Environment Variable Description Default Value
DEBUG Enable verbose debug output False
PORT The port to serve the Flask app 5000
SWAGGER_URL local or remote URL to the Swagger spec that this application uses openapi/swagger.json

Database Connection Config

You can choose to connect to a remote postgres instance, or use a local SQLite file (recommended for dev only)

Environment Variable Description Default Value
USE_SQLITE Use a local database file (instead of postgres, for local dev only) True
POSTGRES_HOST Hostname of a remote Postgres to connect to localhost
POSTGRES_PORT Port of a remote Postgres to connect to 5432
POSTGRES_USER Username to use when connecting to remote Postgres ''
POSTGRES_PASS Password to use when connecting to remote Postgres ''
POSTGRES_DB Database to use when connecting to remote Postgres ct2019db

NOTE: By default, a sqlite file will be created.

Getting Started

This project can either be run with Python or as a Docker container.

To run all of ClassTranscribe locally (including the frontend and C# backend) see RunEverything.md

With Python

Install dependencies:

pip install -r requirements.txt

Run the application:

python server.py

Navigate to http://localhost:5000/ui/ to test the API with Swagger UI.

With Docker

Build the Docker image:

docker build -t classtranscribe/pyapi .

Run a Docker container from that image:

docker run -itd --name ct-pyapi -p 5000:5000 classtranscribe/pyapi

Navigate to http://localhost:5000/ui/ to test the API with Swagger UI.

NOTE: In Docker on Mac/Windows, you may need to use your IP address instead of localhost.

With Docker Compose

Build and run the pyapi application, along with postgres and rabbitmq:

docker compose -f docker/docker-compose.yml up -d --build

You can change the code and/or .env files located in the Docker directory to change the behavior of the application.

NOTE: --build will automatically rebuild the Docker image needed for this stack

Navigate to http://localhost:5000/ui/ to test the API with Swagger UI.

NOTE: In Docker on Mac/Windows, you may need to use your IP address instead of localhost.

pyapi's People

Contributors

angrave avatar bodom0015 avatar robkooper avatar lijiaxi2018 avatar

Stargazers

Kalvin Yang avatar APCBC avatar Pete Stenger avatar

Watchers

 avatar Tim Yang avatar  avatar Harsh Deep avatar Pramod Joshi avatar Kalvin Yang avatar

pyapi's Issues

jwt token on startup

glossary | 2022-12-07T19:05:17.230592220Z agent.listener.QueueAwaker 2022-12-07 19:05:17,230 Failed to update jwt token: HTTPConnectionPool(host='api', port=80): Max retries exceeded with url: /api/Account/MediaWorkerSignIn (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f110f8a1910>: Failed to establish a new connection: [Errno 111] Connection refused'))

Need to slow down jwt re-attempts e.g. once per 10s because the api container may not yet be ready to serve api requests

Crawler exception on non-ascii

crawler | aslcore-engineering-karnaugh map-1-312769046
crawler |
crawler | Not Saved
crawler | agent.listener.TaskNames.PythonCrawler 2023-11-14 05:44:57,148 [1] PythonCrawler failed to look up for a specific term: 'latin-1' codec can't encode character '\u2019' in position 52: ordinal not in range(256)

Docker build is broken (psycopg2-binary not install)

2022-10-25T22:44:18.3346197Z Collecting psycopg2-binary==2.9.3
2022-10-25T22:44:18.3480220Z   Downloading psycopg2-binary-2.9.3.tar.gz (380 kB)
2022-10-25T22:44:18.3518532Z      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 380.6/380.6 kB 346.8 MB/s eta 0:00:00
2022-10-25T22:44:18.4060707Z   Preparing metadata (setup.py): started
2022-10-25T22:44:18.6321617Z   Preparing metadata (setup.py): finished with status 'error'
2022-10-25T22:44:18.6376068Z �[91m  error: subprocess-exited-with-error
2022-10-25T22:44:18.6376625Z   
2022-10-25T22:44:18.6377030Z   × python setup.py egg_info did not run successfully.
2022-10-25T22:44:18.6377375Z   │ exit code: 1

2022-10-25T22:44:18.6377694Z   ╰─> [25 lines of output]
2022-10-25T22:44:18.6378394Z       /usr/local/lib/python3.11/site-packages/setuptools/config/setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
2022-10-25T22:44:18.6378897Z         warnings.warn(msg, warning_class)
2022-10-25T22:44:18.6379173Z       running egg_info
2022-10-25T22:44:18.6379607Z       creating /tmp/pip-pip-egg-info-qz66q5ln/psycopg2_binary.egg-info
2022-10-25T22:44:18.6380147Z       writing /tmp/pip-pip-egg-info-qz66q5ln/psycopg2_binary.egg-info/PKG-INFO
2022-10-25T22:44:18.6380793Z       writing dependency_links to /tmp/pip-pip-egg-info-qz66q5ln/psycopg2_binary.egg-info/dependency_links.txt
2022-10-25T22:44:18.6381442Z       writing top-level names to /tmp/pip-pip-egg-info-qz66q5ln/psycopg2_binary.egg-info/top_level.txt
2022-10-25T22:44:18.6382071Z       writing manifest file '/tmp/pip-pip-egg-info-qz66q5ln/psycopg2_binary.egg-info/SOURCES.txt'
2022-10-25T22:44:18.6382426Z       
2022-10-25T22:44:18.6382694Z       Error: pg_config executable not found.
2022-10-25T22:44:18.6382953Z       
2022-10-25T22:44:18.6383280Z       pg_config is required to build psycopg2 from source.  Please add the directory
2022-10-25T22:44:18.6383712Z       containing pg_config to the $PATH or specify the full executable path with the
2022-10-25T22:44:18.6384036Z       option:
2022-10-25T22:44:18.6384250Z       
2022-10-25T22:44:18.6384655Z           python setup.py build_ext --pg-config /path/to/pg_config build ...
2022-10-25T22:44:18.6384958Z       
2022-10-25T22:44:18.6385311Z       or with the pg_config option in 'setup.cfg'.
2022-10-25T22:44:18.6385576Z       
2022-10-25T22:44:18.6385902Z       If you prefer to avoid building psycopg2 from source, please install the PyPI
2022-10-25T22:44:18.6386333Z       'psycopg2-binary' package instead.
2022-10-25T22:44:18.6386594Z       
2022-10-25T22:44:18.6387005Z       For further information please check the 'doc/src/install.rst' file (also at
2022-10-25T22:44:18.6387410Z       <https://www.psycopg.org/docs/install.html>).
2022-10-25T22:44:18.6387692Z       
2022-10-25T22:44:18.6387915Z       [end of output]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.