Skip to content

Commit

Permalink
Task cancel reconverge linting (#656)
Browse files Browse the repository at this point in the history
* Fix linting on funcx_sdk/funcx/tests/

* Simplify instructions for installing endpoint secrets to cluster

* Fix CI and the way dependencies are specified

test and dev are extras for installing tools, no multiple requirements
files scattered across the repo.

CI workflows should not be installing multiple distinct applications
into a single venv and then trying to test. This muddies the waters
and makes the purpose and requirements of each CI step unclear.

Therefore, in addition to putting the requirement data where it really
belongs, this fixes the workflows to specify a better isolated test
configuration.

Workflow jobs are used more thoughtfully to produce isolated VMs for
distinct build and testing processes.

New daily tests run Monday-through-Friday in the AM for US timezones,
doing `safety check` and little else. Safety checking on dependencies
is done separately for funcx-sdk and funcx-endpoint.

The CI workflow for testing PRs and branches also does `safety check`,
but importantly the hourly test does not.

Notifications from the daily and hourly workflows are done in a
separate dedicated job. This means that new jobs can be added upstream
without needing distinct or rewritten notification logic.

The absence of any pytest run for the funcx-sdk package is more
obvious and identified properly as a problem. It is paired with the
"import test" so that when enabled, the import test removal will be
localized to the same area of the workflow file.

Linting is a dedicated job which runs as part of the CI workflow and
uses pre-commit on the full repo. No additional lint steps (e.g.
one-off flake8 runs) are used or should be needed.

Testing documentation is updated minimally to refer to the
installation of extras, rather than requirements files.

The doc site requirements for some (undocumented) reason are
installing funcx-sdk test requirements. This has been removed. Any
documentation requirements can continue to be specified in the doc
directory, or under a new `[docs]` extra if necessary. It should not
"inherit" the requirements of the testing process.

The codecov integration does not deliver value in the absence of good
unit testing and a test matrix of size greater than 1. Therefore,
until such a time as codecov is useful and a worthwhile configuration
can be identified, the integration has been removed.

The funcx-endpoint setup.py file was autoformatted with `black` to
simplify the formatting of the requirements data.

No workflow steps are allowed to use `actions/checkout@master`. This
is unnecessary and dangerous usage. `checkout@v2` is used -- as the
GitHub Action's own documentation instructs users to do -- instead.

* Port parsl BadRegistration error message clarification to funcx fork

This clarification was introduced as part of
Parsl/parsl#980

I have not examined the rest of that PR for relevance to this fork.

* Remove unused BadRegistration exception class

This looks like it was excessive copy-paste from Parsl source code which
has had an unused BadRegistration class since parsl PR
Parsl/parsl#1671

* Broaden htex interchange->executor error message phrasing

Previously the error message claimed that the fatal error was due to
version mismatch.

This is not true: this same fatal error may occur in the case of a
BadRegistration.

This PR rephrases the error to be less misleading.

I have encountered this repeatedly during review of #909, and at
least I think Yadu was getting it while hacking on this code.

* Expand daily build to all days

* Remove internal RedisQueue object and dependents

RedisQueue is now provided by funcx-common if needed.

1. Remove `funcx_endpoint.queues`
2. Remove `funcx_endpoint/tests/integration/test_redis.py`
   (this just tests the removed subpackage)
3. Remove `funcx_endpoint.mock_broker`, which relies on RedisQueue

(3) is the most questionable of these three. However, `mock_broker`
does not appear to be used anywhere. Furthermore, even if a mocked
Forwarder object is needed for some reason, there doesn't appear to be
any reason that it should be provided by the `funcx-endpoint` package.

* Update smoke test config with version, dev env

version=0.3.5

add a "dev" block to the config for ease of use.

black and isort on the file

* Make smoke tests check min version, not exact

Check against the API response with a loose version comparison, not an
equality check. This means that the smoke tests set a "floor" for what
versions are allowed, but do not fail when a release is done.

* Add a Polaris config example

* Flake8

* Removing comment # edtb-02

* Update linting config and fix

Remove flake8 ignores for various rules: only ignore the rules which
must be ignored to be black-compatible.

Remove exclusions from pre-commit config.

* Fix subject line in hourly smoke test

* Remove async testing until it can be done safely

* Adding a minimal s3 smoke test

* Adding funcx_endpoint to install list

* Marking test for large args to skip

* Adding fixme note to gh workflow, and minor fixes to tests.

* Remove all use of async code from smoke tests

Do not use the executor interface until it can be repaired. Use a
simple polling loop to wait for results.

Turn off throttling on the client so that we don't spuriously fail a
job.

* Begin login config rewrite

Structure logging config more tightly, removing odd naming and highly
dynamic, imperative configuration of loggers.

The new structure is that there is a single method which can be used
to reconfigure logging on an as-needed basis (e.g. to turn off logging
to stdio).

Logging is configured at each entrypoint, and in one special case when
a daemon is being launched.

All loggers are initialized in module scope as

    log = logging.getLogger(__name__)

Any logger creation not matching this exact pattern is considered
incorrect and is fixed to match.

* Update logging in Interchange

- Use setup_logging() to replace global logger object configured via
  set_file_logger()
- Cleanup CLI argument passing, as it relates to logging arguments
- Remove logging attributes from the Interchange object

This should, for the most part, not change the semantics of any code.
However, it is worth noting that it reduces the maxbytes on the
logfile from 256MB to 100MB. This could be adjusted back up by
allowing `setup_logging()` to take a parameter for maxbytes, but for
now this is not being done.

* Fix logging configuration in worker

Also cleanup use of loggers in various modules where impact is low.

* Fix various issues in logging refactor

log_max_bytes is no longer supported and needs to be removed.
logging_level similarly needs to be removed. console logging needs to
be disabled within the daemon.

* Remove logging helpers; fix "asyncio" logger

These were originally going to be left untouched, but the fact that
they were configuring logging for "asyncio" makes it hard to see a way
to salvage them.

The logger for "asyncio" _does not_ belong to funcx. We absolutely
should not be using that logger internally for funcx-related
activities.

Fix the references to the "asyncio" logger to use `__name__` as is
normal, and remove the imperative logging configuration helpers.

* Install funcx_endpoint for smoke tests

* Patch default logfile in tests to handle CI

In GitHub actions, the logfile handler fails to configure. The exact
cause is unclear, but it may be that there's an issue with
access to the default logfile or the default log directory. Put the
default log path into a tmpdir to fix this.

* Raise result size limit to 10MB

And fix `sys.getsizeof` on a bytestring to use `len` instead.

* WSPollingTask now has a close method and handle_incoming return False on remote disconnect.

The executor closes and reconnects WS on remote disconnect.

* Adding a long duration test.

* Relax version match constraints (#637)

* Relax version requirements

* Adding test scripts that launch endpoint and workers of mismatched python version for tests.

* Removing the `relax_manager_version_match` option.

The interchange will note an info line if there's some version mismatch and continue. This can later be problematic if the funcx versions do not match.

* Updating configs and README with note to update paths to user conda.

* Module import ordering fixes for isort

* Black auto-fixes

* Be explicit about how to create conda environments

* Make update_all fail when a component fails

* Adding a test that raises an exception on the worker side

* use unixy exit codes

* abort tests on failure rather than continuing fairly quietly - this makes a test failure more obvious

* Add another test to kill worker

* Minor format fix

* Remove unnecessary f-string

* logger -> log

Co-authored-by: Ben Clifford <[email protected]>

* Fix broken link to parsl docs

* (Re)Apply all autofixers

black, isort, and pyupgrade are all (re)converged on the files
modified under the task-cancel branch.

* Apply changes from 'main' to task-cancel

This is the result of
- `git checkout --patch main`
- manual edits to make each file agree with flake8 and other linting

Co-authored-by: Ben Galewsky <[email protected]>
Co-authored-by: Ben Clifford <[email protected]>
Co-authored-by: Yadu Nand Babuji <[email protected]>
Co-authored-by: Ryan Chard <[email protected]>
Co-authored-by: Wes Brewer <[email protected]>
Co-authored-by: Daniel S. Katz <[email protected]>
  • Loading branch information
7 people authored Jan 7, 2022
1 parent 54cb786 commit cd28da2
Show file tree
Hide file tree
Showing 115 changed files with 4,744 additions and 3,792 deletions.
29 changes: 3 additions & 26 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
[flake8]
# TODO: remove all of these ignores other than W503,W504,B008
# `black` will handle enforcement of styling, and we will have no opinionated
# ignore rules
# any cases in which we actually need to ignore a rule (e.g. E402) we will mark
# the relevant segment with noqa comments as necessary
#
# D203: 1 blank line required before class docstring
# E124: closing bracket does not match visual indentation
# E126: continuation line over-indented for hanging indent
# This one is bad. Sometimes ordering matters, conditional imports
# setting env vars necessary etc.
# E402: module level import not at top of file
# E129: Visual indent to not match indent as next line, counter eg here:
# https://github.com/PyCQA/pycodestyle/issues/386
#
# E203,W503,W504: conflict with black formatting sometimes
# B008: a flake8-bugbear rule which fails on idiomatic typer usage (consider
# re-enabling this once everything else is fixed and updating usage)
ignore = D203, E124, E126, E402, E129, W605, W503, W504, E203, F401, B008
[flake8] # black-compatible
ignore = W503, W504, E203, B008
# TODO: reduce this to 88 once `black` is applied to all code
max-line-length = 160
exclude = parsl/executors/serialize/, test_import_fail.py
# F632 is comparing constant literals with == instead of "is"
per-file-ignores = funcx_sdk/funcx/sdk/client.py:F632,
funcx_endpoint/funcx/endpoint/auth.py:F821,
funcx_endpoint/funcx/serialize/base.py:F821
max-line-length = 88
115 changes: 55 additions & 60 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,73 +9,68 @@ on:
pull_request:

jobs:
test:
strategy:
matrix:
python-version: [3.7]
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- name: install pre-commit
run: |
python -m pip install -U pip setuptools wheel
python -m pip install pre-commit
- name: run pre-commit
run: pre-commit run -a

test-sdk:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Get latest pip version
run: |
python -m pip install --upgrade pip setuptools wheel
- name: Lint
run: |
pip install pre-commit
pre-commit run -a
- name: Install dependencies for funcx-sdk
run: |
python -m pip install -r funcx_sdk/requirements.txt
python -m pip install -r funcx_sdk/test-requirements.txt
pip list
- name: Check for vulnerabilities in libraries
run: |
pip install safety
pip freeze | safety check
- name: Test sdk by just importing
run: |
cd funcx_sdk
pip install .
python -c "from funcx.sdk.client import FuncXClient"
cd ..
# - name: Test with pytest
# run: |
# pytest
- name: Install dependencies for funcx-endpoint
run: |
python -m pip install -r funcx_endpoint/requirements.txt
python -m pip install -r funcx_endpoint/test-requirements.txt
pip list
- name: Check for vulnerabilities in libraries
run: |
pip install safety
pip freeze | safety check
- name: Test funcx-endpoint by just importing
run: |
cd funcx_endpoint
pip install .
python -c "from funcx_endpoint.version import VERSION"
funcx-endpoint -v
cd ..
- name: Lint with Flake8
run: |
flake8 funcx_endpoint
- name: Test with pytest
run: |
PYTHONPATH=funcx_endpoint python -m coverage run -m pytest funcx_endpoint/tests/funcx_endpoint
- name: Report coverage with Codecov
run: |
codecov --token=${{ secrets.CODECOV_TOKEN }}
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: install requirements
run: |
python -m pip install -U pip setuptools wheel
python -m pip install './funcx_sdk[test]'
pip install safety
- name: run safety check
run: safety check

# TODO: remove this test
# This is the weakest test which does anything, checking that the client can
# be imported. As soon as pytest is running again, remove this.
- name: check importable
run: python -c "from funcx.sdk.client import FuncXClient"
# - name: run pytest
# run: |
# cd funcx_sdk
# pytest

test-endpoint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: install requirements
run: |
python -m pip install -U pip setuptools wheel
python -m pip install './funcx_endpoint[test]'
pip install safety
- name: run safety check
run: safety check
- name: run pytest
run: |
PYTHONPATH=funcx_endpoint python -m coverage run -m pytest funcx_endpoint/tests/funcx_endpoint
publish:
# only trigger on pushes to the main repo (not forks, and not PRs)
if: ${{ github.repository == 'funcx-faas/funcX' && github.event_name == 'push' }}
needs: test
needs:
- lint
- test-sdk
- test-endpoint
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/daily.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: daily
on:
# build every day at 4:00 AM UTC
schedule:
- cron: '0 4 * * *'
workflow_dispatch:

jobs:
safety-check-sdk:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: main
- uses: actions/setup-python@v1
- name: install requirements
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install './funcx_sdk'
python -m pip install safety
- name: run safety check
run: safety check

safety-check-endpoint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: main
- uses: actions/setup-python@v1
- name: install requirements
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install './funcx_endpoint'
python -m pip install safety
- name: run safety check
run: safety check

notify:
runs-on: ubuntu-latest
needs:
- safety-check-sdk
- safety-check-endpoint
if: failure()
steps:
# FIXME: make this send to a listhost or Slack
- name: Send mail
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
subject: ${{ github.repository }} - Daily Check ${{ job.status }}
to: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
from: funcX Tests # <[email protected]>
body: The daily ${{ github.repository }} workflow failed!
43 changes: 23 additions & 20 deletions .github/workflows/hourly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
description: "manual test"

jobs:
tutorial_test:
smoke-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -22,25 +22,28 @@ jobs:
- name: Install dependencies for funcx-sdk and test requirements
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install ./funcx_sdk
python -m pip install -r funcx_sdk/test-requirements.txt
- name: Check for vulnerabilities in libraries
run: |
pip install safety
safety check
python -m pip install './funcx_sdk[test]'
# fixme: Remove this next install line once issue #640 is fixed.
python -m pip install './funcx_endpoint'
python -m pip install safety
- name: Run smoke tests to check liveness of hosted services
run: |
pytest -v funcx_endpoint/tests/smoke_tests --api-client-id ${{ secrets.API_CLIENT_ID }} --api-client-secret ${{ secrets.API_CLIENT_SECRET }}
# FIXME: make this send to a listhost or Slack
- name: Send mail
if: ${{ failure() }}
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
subject: ${{ github.repository }} - Tutorial test ${{ job.status }}
to: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
from: funcX Tests # <[email protected]>
body: The ${{ github.repository }} test ${{ github.workflow }} exited with status - ${{ job.status }}!
notify:
runs-on: ubuntu-latest
needs: [smoke-test]
if: failure()
steps:
# FIXME: make this send to a listhost or Slack
- name: Send mail
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
subject: ${{ github.repository }} - Hourly smoke test failed
to: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
from: funcX Tests # <[email protected]>
body: The hourly ${{ github.repository }} workflow failed!
10 changes: 4 additions & 6 deletions .github/workflows/smoke_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ jobs:
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies for funcx-sdk and test requirements
- name: install requirements
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install ./funcx_sdk
python -m pip install -r funcx_sdk/test-requirements.txt
- name: Test sdk by just importing
run: |
python -c "from funcx.sdk.client import FuncXClient"
python -m pip install './funcx_sdk[test]'
# fixme: Remove this next install line once issue #640 is fixed.
python -m pip install './funcx_endpoint'
- name: Run smoke tests to check liveness of hosted services
run: |
pytest -v funcx_endpoint/tests/smoke_tests --api-client-id ${{ secrets.API_CLIENT_ID }} --api-client-secret ${{ secrets.API_CLIENT_SECRET }}
12 changes: 0 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ repos:
hooks:
- id: check-merge-conflict
- id: trailing-whitespace
# FIXME: temporary exclude to reduce conflicts, remove this
exclude: ^funcx_endpoint/
# end FIXME
- repo: https://github.com/sirosen/check-jsonschema
rev: 0.3.1
hooks:
Expand All @@ -19,27 +16,18 @@ repos:
rev: 21.5b1
hooks:
- id: black
# FIXME: temporary exclude to reduce conflicts, remove this
exclude: ^funcx_endpoint/
# end FIXME
- repo: https://github.com/timothycrosley/isort
rev: 5.8.0
hooks:
- id: isort
# explicitly pass settings file so that isort does not try to deduce
# which settings to use based on a file's directory
args: ["--settings-path", ".isort.cfg"]
# FIXME: temporary exclude to reduce conflicts, remove this
exclude: ^funcx_endpoint/
# end FIXME
- repo: https://github.com/asottile/pyupgrade
rev: v2.17.0
hooks:
- id: pyupgrade
args: ["--py36-plus"]
# FIXME: temporary exclude to reduce conflicts, remove this
exclude: ^funcx_endpoint/
# end FIXME
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
Expand Down
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,18 @@ After installing `pre-commit`, run
in the repo to configure hooks.

> NOTE: If necessary, you can always skip hooks with `git commit --no-verify`
## Installing Testing Requirements

Testing requirements for each of the two packages in this repository
(funcx-sdk and funcx-endpoint) are specified as installable extras.

To install the funcx-sdk test requirements

cd funcx_sdk
pip install '.[test]'

To install the funcx-endpoint test requirements

cd funcx_endpoint
pip install '.[test]'
4 changes: 1 addition & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
import os
import sys

import requests

sys.path.insert(0, os.path.abspath("../funcx_sdk/"))
import funcx
import funcx # noqa:E402

# -- Project information -----------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/configs/bluewaters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# PLEASE UPDATE user_opts BEFORE USE
user_opts = {
'bluewaters': {
'worker_init': 'module load bwpy;source anaconda3/etc/profile.d/conda.sh;conda activate funcx_testing_py3.7',
'worker_init': 'module load bwpy;source anaconda3/etc/profile.d/conda.sh;conda activate funcx_testing_py3.7', # noqa: E501
'scheduler_options': '',
}
}
Expand Down
Loading

0 comments on commit cd28da2

Please sign in to comment.