Skip to content

Commit

Permalink
Add pylint GH action
Browse files Browse the repository at this point in the history
For initial stage, enable all checks for now

Signed-off-by: Yihong Wang <yh.wang@ibm.com>
  • Loading branch information
yhwang committed May 24, 2024
1 parent 9f671c4 commit a2e797c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 16 deletions.
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/requirementes.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

0 comments on commit a2e797c

Please sign in to comment.