Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pylint GH action #2

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Pylint

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r server/requirements.txt
pip install pylint
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')

32 changes: 16 additions & 16 deletions server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def submit_job():
('--num_fewshot', None if request.json.get('num_fewshot')
is None else str(request.json.get('num_fewshot'))),
('--gen_kwargs', request.json.get('gen_kwargs')),
# TODO disable as CLI arg- set to `/output` then return results.json when it's done
# disable as CLI arg- set to `/output` then return results.json when it's done (fixme)
('--output_path', request.json.get('output_path')),
# either present or not
('--log_samples', request.json.get('log_samples')),
Expand Down Expand Up @@ -160,21 +160,21 @@ def _background_task(task_id):
f"{_OUTPUT_PATH}/{task_id}/stderr.log", 'w', encoding="utf-8"
) as stderr:

process = subprocess.Popen(
cmd, stdout=stdout, stderr=stderr, universal_newlines=True)

while not _jobs[task_id].get(_CANCEL_KEY, False) and process.returncode is None:
try:
# Execute the command and handle cancellation every
# 10 seconds
process.wait(timeout=10)
except subprocess.TimeoutExpired:
pass

# handle the cancel case before closing the stderr and stdout
if _jobs[task_id].get(_CANCEL_KEY, False):
process.kill()
_jobs[task_id][_STATUS_KEY] = _STATUS_CANCEALLED
with subprocess.Popen(
cmd, stdout=stdout, stderr=stderr, universal_newlines=True) as process:

while not _jobs[task_id].get(_CANCEL_KEY, False) and process.returncode is None:
try:
# Execute the command and handle cancellation every
# 10 seconds
process.wait(timeout=10)
except subprocess.TimeoutExpired:
pass

# handle the cancel case before closing the stderr and stdout
if _jobs[task_id].get(_CANCEL_KEY, False):
process.kill()
_jobs[task_id][_STATUS_KEY] = _STATUS_CANCEALLED

# handle non-cancel case here
if not _jobs[task_id].get(_CANCEL_KEY, False):
Expand Down
Loading