Skip to content

Vinceorz/YORG-AI

Repository files navigation

YORG AI

A brief description of the project.

How to install

  1. Clone the repository.

  2. Install the required dependencies using pip:

    pip install -r requirements.txt

Pre-Commit Hooks

The pre-commit git hooks consists on run some checks before confirm or commit your staged changes on the local repo, the .pre-commit-config.yml file contains the checks.
https://pre-commit.com/
https://pypi.org/project/pre-commit/

To set it up, you need to run this command on the root folder of the project

(venv)$ pre-commit install

It runs each time you try to commit your changes, or you can just run it manually

(venv)$ pre-commit run --all-files

The following local checks are implemented:

  • Linting with PyLint
(venv)$ pylint *

Usage

Start the application using the following command:

docker-compose up --build

If it fails: "set: illegal option -"

Try this: sed -i 's/\r$//' entrypoint.sh

Then, open your web browser and navigate to: http://localhost:8000/docs

Debug

VSCode

Debug Simple Node/Assignment

  1. Add debug configuration in .vscode/launch.json

    {
        "version": "0.2.0",
        "configurations": [
            {
            "name": "Python: Remote Attach",
            "type": "python",
            "request": "attach",
            "port": 5678,
            "host": "localhost",
            "pathMappings": [
                {
                "localRoot": "${workspaceFolder}",
                "remoteRoot": "/app"
                }
            ]
            }
        ]
    }
  2. Add some breakpoints.

  3. Start the application using the following command:

    docker-compose -f docker-compose.debug.yml up
    
  4. Click Python: Remote Attach buttom in Run And Debug sidebar.

Debug startup.py

  1. Add debug configuration in .vscode/launch.json

    {
        "version": "0.2.0",
        "configurations": [
            {
            "name": "Python: Remote Attach",
            "type": "python",
            "request": "attach",
            "port": 5678,
            "host": "localhost",
            "pathMappings": [
                {
                "localRoot": "${workspaceFolder}",
                "remoteRoot": "/app"
                }
            ]
            }
        ]
    }
  2. Run docker-compose up --build

  3. Run debug_startup.sh

  4. Click Python: Remote Attach buttom in Run And Debug sidebar.

Debug Jupyter YKernel

  1. Add debug configuration in .vscode/launch.json

    {
        "version": "0.2.0",
        "configurations": [
            {
            "name": "Python: Remote Attach",
            "type": "python",
            "request": "attach",
            "port": 5678,
            "host": "localhost",
            "pathMappings": [
                {
                "localRoot": "${workspaceFolder}",
                "remoteRoot": "/app"
                }
            ]
            }
        ]
    }
  2. Modify kernel.json

{
    "argv": [
        "python",
        "-m",
        "debugpy",
        "--wait-for-client",
        "--listen",
        "0.0.0.0:5678",
        "-m",
        "src.service.ykernel.ykernel",
        "-f",
        "{connection_file}"
    ],
    "display_name": "YKernel"
}
  1. Run docker-compose up --build

  2. Click Python: Remote Attach buttom in Run And Debug sidebar.

Testing

To run the tests, execute the following command:

docker-compose exec fastapi python -m pytest -s src/tests

Contributing

  1. Fork the repository.

  2. Create a new branch:

    git checkout -b my-new-feature
  3. Make changes and commit them:

    git commit -am 'Add some feature'
  4. Push to the branch:

    git push origin my-new-feature
  5. Submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.