File size: 6,163 Bytes
aa19284
25f8cac
a100ffb
 
 
df21dce
28bb969
148b3a7
df21dce
 
a100ffb
 
148b3a7
28bb969
148b3a7
a100ffb
 
 
 
72dc01c
698d616
 
eea7daa
 
000f989
a100ffb
 
1122900
bedf085
c01fb54
f77beb1
276bab1
f77beb1
bedf085
f77beb1
 
62ecf50
 
 
 
e7941a7
a100ffb
3a1fd74
a100ffb
6da5944
a100ffb
 
b83cddb
6238194
f88031e
 
e8815be
a100ffb
5afff31
a100ffb
 
fc23c11
a100ffb
 
 
043980c
 
47ce661
06aebb6
 
65159ce
 
c48a68e
46f8a60
3d7c303
698d616
41e5fd5
 
4655d23
41e5fd5
698d616
4655d23
3d7c303
d18011f
4655d23
3d7c303
698d616
4655d23
3a3dce0
3ca1cbf
 
cabda12
cd171e8
ebef609
099a9c6
24a4349
 
 
 
 
bedf085
24a4349
 
 
bedf085
24a4349
 
 
 
 
 
 
 
 
 
 
099a9c6
 
 
 
 
 
 
bedf085
099a9c6
e7941a7
099a9c6
3a1fd74
14e466a
00700f0
14e466a
 
 
 
 
099a9c6
afbb8a4
099a9c6
 
 
 
 
5698780
099a9c6
07a6991
6238194
f88031e
09c365a
e8815be
099a9c6
 
 
043980c
099a9c6
4320392
099a9c6
cd171e8
 
e7941a7
099a9c6
cd171e8
eea7daa
 
 
cd171e8
 
 
 
 
 
 
 
b896bd3
 
 
 
 
 
 
 
 
9fd88bc
bedf085
 
9fd88bc
b896bd3
 
3a1fd74
b896bd3
5afff31
b896bd3
 
 
 
 
 
043980c
 
9fd88bc
 
bedf085
b896bd3
9fd88bc
bedf085
9fd88bc
 
bedf085
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: Linux

on:
  push:
    branches:
      - '**'
    paths:
      - '**'
    tags:
      - 'v*.*.*'
  pull_request:
    branches:
      - 'master'
    paths:
      - '**'

jobs:
  test:
    runs-on: ${{ matrix.os }}
    timeout-minutes: 60
    env:
      COVERAGE_PROCESS_START: "${{ github.workspace }}/.coveragerc"
    defaults:
      run:
        shell: bash
    strategy:
      matrix:
        julia-version: ['1']
        python-version: ['3.12']
        os: [ubuntu-latest]
        test-id: [main]
        include:
          - julia-version: '1.6'
            python-version: '3.8'
            os: ubuntu-latest
            test-id: include
          - julia-version: '1'
            python-version: '3.12'
            os: ubuntu-latest
            test-id: include

    steps:
      - uses: actions/checkout@v4
      - name: "Set up Julia"
        uses: julia-actions/setup-julia@v2
        with:
          version: ${{ matrix.julia-version }}
      - name: "Cache Julia"
        uses: julia-actions/cache@v2
        with:
          cache-name: ${{ matrix.os }}-test-${{ matrix.julia-version }}-${{ matrix.python-version }}
          cache-packages: false
      - name: "Set up Python"
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
          cache: pip
      - name: "Install PySR"
        run: |
            python -m pip install --upgrade pip
            pip install .
            python -c 'import pysr'
      - name: "Assert Julia version"
        if: ${{ matrix.julia-version != '1'}}
        run: python3 -c "from pysr import jl; assert jl.VERSION.major == jl.seval('v\"${{ matrix.julia-version }}\"').major; assert jl.VERSION.minor == jl.seval('v\"${{ matrix.julia-version }}\"').minor"
      - name: "Install test dependencies"
        run: pip install coverage coveralls pytest nbval
      - name: "Set up coverage for subprocesses"
        run: echo 'import coverage; coverage.process_startup()' > "${{ github.workspace }}/sitecustomize.py"
      - name: "Run tests"
        run: coverage run -m pysr test main,cli,startup
      - name: "Install JAX"
        run: pip install jax jaxlib # (optional import)
        if: ${{ matrix.test-id == 'main' }}
      - name: "Run JAX tests"
        run: coverage run --append -m pysr test jax
        if: ${{ matrix.test-id == 'main' }}
      - name: "Install Torch"
        run: pip install torch # (optional import)
        if: ${{ matrix.test-id == 'main' }}
      - name: "Run Torch tests"
        run: coverage run --append -m pysr test torch
        if: ${{ matrix.test-id == 'main' }}
      - name: "Coveralls"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          COVERALLS_FLAG_NAME: test-${{ matrix.julia-version }}-${{ matrix.python-version }}-${{ matrix.test-id }}
          COVERALLS_PARALLEL: true
        run: coveralls --service=github

  dev_install:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: ['ubuntu-latest']
        python-version: ['3.12']
        julia-version: ['1']
        include:
          - os: ubuntu-latest
            python-version: '3.8'
            julia-version: '1.6'
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
      - name: "Install PySR"
        run: |
            python -m pip install --upgrade pip
            pip install .
      - name: "Run development test"
        run: PYSR_TEST_JULIA_VERSION=${{ matrix.julia-version }} PYSR_TEST_PYTHON_VERSION=${{ matrix.python-version }} python -m pysr test dev

  conda_test:
    runs-on: ${{ matrix.os }}
    defaults:
      run:
        shell: bash -l {0}
    strategy:
      matrix:
        python-version: ['3.12']
        os: ['ubuntu-latest']

    steps:
      - uses: actions/checkout@v4
      - name: "Cache conda"
        uses: actions/cache@v4
        env:
          CACHE_NUMBER: 0
        with:
          path: ~/conda_pkgs_dir
          key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }}
      - name: "Set up Conda"
        uses: conda-incubator/setup-miniconda@v3
        with:
          miniforge-variant: Mambaforge
          miniforge-version: latest
          auto-activate-base: true
          python-version: ${{ matrix.python-version }}
          activate-environment: pysr-test
          environment-file: environment.yml
      - name: "Cache Julia"
        uses: julia-actions/cache@v2
        with:
          cache-name: ${{ matrix.os }}-conda-${{ matrix.python-version }}
          cache-packages: false
      - name: "Install PySR"
        run: |
            python3 -m pip install .
            python3 -c 'import pysr'
      - name: "Run tests"
        run: cd /tmp && python -m pysr test main

  coveralls:
    name: Indicate completion to coveralls.io
    needs:
      - test
    runs-on: ubuntu-latest
    defaults:
      run:
        shell: bash -l {0}
    container: python:3-slim
    steps:
      - name: Finished
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
            pip install coveralls
            coveralls --finish

  types:
    name: Check types
    runs-on: ubuntu-latest
    defaults:
      run:
        shell: bash -l {0}
    strategy:
      matrix:
        python-version:
          - '3.12'
          - '3.8'
        os: ['ubuntu-latest']

    steps:
      - uses: actions/checkout@v4
      - name: "Set up Python"
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
          cache: pip
      - name: "Install PySR and all dependencies"
        run: |
            python -m pip install --upgrade pip
            pip install .
            pip install mypy
      - name: "Install additional dependencies"
        run: python -m pip install jax jaxlib torch
        if: ${{ matrix.python-version != '3.8' }}
      - name: "Run mypy"
        run: python -m mypy --install-types --non-interactive pysr
        if: ${{ matrix.python-version != '3.8' }}
      - name: "Run compatible mypy"
        run: python -m mypy --ignore-missing-imports pysr
        if: ${{ matrix.python-version == '3.8' }}