diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml new file mode 100644 index 0000000..7d33569 --- /dev/null +++ b/.github/workflows/pylint.yml @@ -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') + diff --git a/server/app.py b/server/app.py index 5b88caa..aafb6ae 100644 --- a/server/app.py +++ b/server/app.py @@ -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')), @@ -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):