diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..93830d4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: CI + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r dev-requirements.txt + pip install -e . + + - name: Set PYTHONPATH + run: echo "PYTHONPATH=$(pwd):$PYTHONPATH" >> $GITHUB_ENV + + - name: Run validation + run: | + if [ -z "$NOVALIDATE" ]; then + make validate + else + echo "skipping validate" + fi + + - name: Run tests with coverage + run: pytest --cov ffx + + - name: Upload coverage to Coveralls + if: matrix.python-version == '3.11' + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + coveralls-endpoint: https://coveralls.io \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3626526..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: python - -jobs: - include: - - python: "3.7" - - python: "3.8" - - python: "3.9" - - python: "3.10" - - python: "3.11" - - python: "3.12" - - python: "3.13" - -install: - - pip install -r dev-requirements.txt - - pip install -e . - -before_script: - - export PYTHONPATH=$(pwd):$PYTHONPATH; - -script: - - '[ -z "$NOVALIDATE" ] && make validate || echo "skipping validate"' - - pytest --cov ffx - -after_success: - - coveralls diff --git a/README.md b/README.md index e2b83b8..a50f036 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # FFX: Fast Function Extraction -[![Build Status at Travis CI](https://travis-ci.org/natekupp/ffx.svg?branch=master)](https://travis-ci.org/natekupp/ffx) +[![CI](https://github.com/natekupp/ffx/workflows/CI/badge.svg)](https://github.com/natekupp/ffx/actions?query=workflow%3ACI) [![Coverage Status](https://coveralls.io/repos/github/natekupp/ffx/badge.svg?branch=master)](https://coveralls.io/github/natekupp/ffx?branch=master) FFX is a technique for symbolic regression. It is: diff --git a/ffx/time_utils.py b/ffx/time_utils.py index cfb8db1..0e60ad9 100644 --- a/ffx/time_utils.py +++ b/ffx/time_utils.py @@ -1,21 +1,13 @@ -import os import signal -import sys import time from contextlib import contextmanager from functools import wraps - -if sys.version_info.major >= 3 and sys.version_info.minor >= 3: - time_fn = time.perf_counter -elif os.name == 'nt': - time_fn = time.clock -else: - time_fn = time.time +from builtins import TimeoutError class TimerResult: def __init__(self): - self.start_time = time_fn() + self.start_time = time.perf_counter() self.end_time = None @property @@ -29,7 +21,7 @@ def millis(self): @contextmanager def time_execution_scope(): - '''Usage: + """Usage: with time_execution_scope() as timer_result: do_some_operation() @@ -39,18 +31,11 @@ def time_execution_scope(): timer_result=timer_result ) ) - ''' + """ timer_result = TimerResult() yield timer_result - timer_result.end_time = time_fn() - - -try: - from builtins import TimeoutError # pylint: disable=unused-import -except ImportError: - # TimeoutError was introduced in python 3.3+ - TimeoutError = OSError + timer_result.end_time = time.perf_counter() def timeout(seconds_before_timeout):