perpetual 2.0.0

A self-generalizing gradient boosting machine that doesn't need hyperparameter optimization
Documentation
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
on:
  pull_request:
  workflow_dispatch:

permissions:
  id-token: write
  contents: read

jobs:
  # 1. Job to create and upload the resources/data files
  prepare-resources:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.11" # Choose a single, compatible python version
          architecture: x64
      - name: Setup uv
        uses: astral-sh/setup-uv@v5
        with:
          enable-cache: true
      - name: Install dependencies for resource creation
        run: |
          uv pip install --system numpy pandas seaborn scikit-learn toml
          cp README.md package-python/README_PYTHON.md
          cp LICENSE package-python/LICENSE  
          cp LICENSE package-r/LICENSE
          mkdir -p resources
          cd package-python
          uv pip install --system -e .[dev]
          cd ..
      - name: Cache resources
        id: cache-resources
        uses: actions/cache@v4
        with:
          path: resources
          key: resources-${{ hashFiles('scripts/make_resources.py') }}
      - name: Build test data (create resources)
        if: steps.cache-resources.outputs.cache-hit != 'true'
        run: python scripts/make_resources.py

  # 2. Windows Build and Test Job (depends on resources)
  windows-build-test:
    if: github.event_name != 'push'
    needs: prepare-resources # This job waits for prepare-resources to complete
    strategy:
      matrix:
        pyversion: ["3.10", "3.11", "3.12", "3.13", "3.14"]
    runs-on: "windows-latest"
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Setup uv
        uses: astral-sh/setup-uv@v5
        with:
          enable-cache: true
      - name: Restore resources cache
        id: restore-resources
        uses: actions/cache@v4
        with:
          path: resources
          key: resources-${{ hashFiles('scripts/make_resources.py') }}
      - name: Install latest stable Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.pyversion }}
          architecture: x64
      - name: Install deps
        run: uv pip install --system numpy pandas seaborn scikit-learn toml
      - run: |
          cp README.md package-python/README_PYTHON.md
          cp LICENSE package-python/LICENSE
          cp LICENSE package-r/LICENSE
      - name: Build test data (Install perpetual with its dev dependencies)
        run: |
          cd package-python
          uv pip install --system -e .[dev]
          cd ..
      - name: Fallback build resources
        if: steps.restore-resources.outputs.cache-hit != 'true'
        run: python scripts/make_resources.py
      - name: Build wheels with maturin
        uses: PyO3/maturin-action@v1
        with:
          target: x86_64
          command: build
          args: --release --strip --interpreter python --manifest-path package-python/Cargo.toml --out dist --sdist
      - name: Install wheel
        run: uv pip install --system perpetual --no-index --find-links dist --no-deps --force-reinstall
      - name: Run Package Tests
        run: |
          uv pip install --system pytest pytest-cov ruff setuptools typing-extensions --upgrade
          cd package-python
          ruff check .
          ruff format --check .
          pytest --cov=perpetual --cov-report=xml tests
          cd ..
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v5
        with:
          use_oidc: true
          slug: ${{ github.repository }}
          directory: ./package-python
          flags: windows,python
          fail_ci_if_error: true
          verbose: true
      - name: Save Artifacts
        uses: actions/upload-artifact@v4
        with:
          name: dist-windows-${{ matrix.pyversion }}
          path: dist

  # 3. macOS Build and Test Job (depends on resources)
  macos-build-test:
    if: github.event_name != 'push'
    needs: prepare-resources
    strategy:
      matrix:
        pyversion: ["3.11", "3.12", "3.13", "3.14"]
        os: [macos-latest, macos-latest-large]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Setup uv
        uses: astral-sh/setup-uv@v5
        with:
          enable-cache: true
      - name: Install OpenMP
        run: brew install libomp
      - name: Restore resources cache
        id: restore-resources
        uses: actions/cache@v4
        with:
          path: resources
          key: resources-${{ hashFiles('scripts/make_resources.py') }}
      - name: Install latest stable Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.pyversion }}
      - name: Install deps
        run: uv pip install --system numpy pandas seaborn scikit-learn toml
      - run: |
          cp README.md package-python/README_PYTHON.md
          cp LICENSE package-python/LICENSE
          cp LICENSE package-r/LICENSE
      - name: Build test data (Install perpetual with its dev dependencies)
        run: |
          cd package-python
          uv pip install --system -e .[dev]
          cd ..
      - name: Fallback build resources
        if: steps.restore-resources.outputs.cache-hit != 'true'
        run: python scripts/make_resources.py
      - name: Build wheels with maturin
        uses: PyO3/maturin-action@v1
        with:
          command: build
          args: --release --strip --interpreter python --manifest-path package-python/Cargo.toml --out dist --sdist
      - name: Install wheel
        run: uv pip install --system perpetual --no-index --find-links dist --no-deps --force-reinstall
      - name: Run Package Tests
        run: |
          uv pip install --system pytest pytest-cov ruff setuptools typing-extensions --upgrade
          cd package-python
          ruff check .
          ruff format --check .
          pytest --cov=perpetual --cov-report=xml tests
          cd ..
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v5
        with:
          use_oidc: true
          slug: ${{ github.repository }}
          directory: ./package-python
          flags: macos,python
          fail_ci_if_error: true
          verbose: true
      - name: Save Artifacts
        uses: actions/upload-artifact@v4
        with:
          name: dist-${{ matrix.os }}-${{ matrix.pyversion }}
          path: dist

  # 4. Linux x64 Build and Test Job (depends on resources)
  linux-build-test:
    if: github.event_name != 'push'
    needs: prepare-resources
    runs-on: ubuntu-latest
    strategy:
      matrix:
        pyversion: ["3.10", "3.11", "3.12", "3.13", "3.14"]
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Setup uv
        uses: astral-sh/setup-uv@v5
        with:
          enable-cache: true
      - name: Restore resources cache
        id: restore-resources
        uses: actions/cache@v4
        with:
          path: resources
          key: resources-${{ hashFiles('scripts/make_resources.py') }}
      - name: Install latest stable Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.pyversion }}
          architecture: x64
      - name: Install deps
        run: uv pip install --system numpy pandas seaborn scikit-learn toml
      - run: |
          cp README.md package-python/README_PYTHON.md
          cp LICENSE package-python/LICENSE
          cp LICENSE package-r/LICENSE
      - name: Build test data (Install perpetual with its dev dependencies)
        run: |
          cd package-python
          uv pip install --system -e .[dev]
          cd ..
      - name: Fallback build resources
        if: steps.restore-resources.outputs.cache-hit != 'true'
        run: python scripts/make_resources.py
      - name: Build wheels with maturin
        uses: PyO3/maturin-action@v1
        with:
          target: x86_64
          manylinux: auto
          command: build
          args: --release --strip --interpreter python${{ matrix.pyversion }} --manifest-path package-python/Cargo.toml --out dist --sdist
      - name: Install wheel
        run: uv pip install --system perpetual --no-index --find-links dist --no-deps --force-reinstall
      - name: Run Package Tests
        run: |
          uv pip install --system pytest pytest-cov ruff setuptools typing-extensions --upgrade
          cd package-python
          ruff check .
          ruff format --check .
          pytest --cov=perpetual --cov-report=xml tests
          cd ..
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v5
        with:
          use_oidc: true
          slug: ${{ github.repository }}
          directory: ./package-python
          flags: linux-x64,python
          fail_ci_if_error: true
          verbose: true
      - name: Save Artifacts
        uses: actions/upload-artifact@v4
        with:
          name: dist-linux-${{ matrix.pyversion }}
          path: dist

  # 5. Linux ARM Build and Test Job (depends on resources)
  linux-arm-build-test:
    if: github.event_name != 'push'
    needs: prepare-resources
    runs-on: ubuntu-24.04-arm
    strategy:
      matrix:
        pyversion: ["3.10", "3.11", "3.12", "3.13", "3.14"]
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Setup uv
        uses: astral-sh/setup-uv@v5
        with:
          enable-cache: true
      - name: Restore resources cache
        id: restore-resources
        uses: actions/cache@v4
        with:
          path: resources
          key: resources-${{ hashFiles('scripts/make_resources.py') }}
      - name: Install latest stable Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.pyversion }}
          architecture: arm64
      - name: Install deps
        run: uv pip install --system numpy pandas seaborn scikit-learn toml
      - run: |
          cp README.md package-python/README_PYTHON.md
          cp LICENSE package-python/LICENSE
          cp LICENSE package-r/LICENSE
      - name: Build test data (Install perpetual with its dev dependencies)
        run: |
          cd package-python
          uv pip install --system -e .[dev]
          cd ..
      - name: Fallback build resources
        if: steps.restore-resources.outputs.cache-hit != 'true'
        run: python scripts/make_resources.py
      - name: Build wheels with maturin
        uses: PyO3/maturin-action@v1
        with:
          manylinux: auto
          command: build
          args: --release --strip --interpreter python${{ matrix.pyversion }} --manifest-path package-python/Cargo.toml --out dist --sdist
      - name: Install wheel
        run: uv pip install --system perpetual --no-index --find-links dist --no-deps --force-reinstall
      - name: Run Package Tests
        run: |
          uv pip install --system pytest pytest-cov ruff setuptools typing-extensions --upgrade
          cd package-python
          ruff check .
          ruff format --check .
          pytest --cov=perpetual --cov-report=xml tests
          cd ..
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v5
        with:
          use_oidc: true
          slug: ${{ github.repository }}
          directory: ./package-python
          flags: linux-arm,python
          fail_ci_if_error: true
          verbose: true
      - name: Save Artifacts
        uses: actions/upload-artifact@v4
        with:
          name: dist-linux-arm-${{ matrix.pyversion }}
          path: dist

  # 6. Cargo Test Job (depends on resources)
  cargo-build-test:
    if: github.event_name != 'push'
    needs: prepare-resources
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Setup uv
        uses: astral-sh/setup-uv@v5
        with:
          enable-cache: true
      - name: Restore resources cache
        id: restore-resources
        uses: actions/cache@v4
        with:
          path: resources
          key: resources-${{ hashFiles('scripts/make_resources.py') }}
      - name: Install latest stable Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"
          architecture: x64
      - name: Install deps
        run: uv pip install --system numpy pandas seaborn scikit-learn toml
      - run: |
          cp README.md package-python/README_PYTHON.md
          cp LICENSE package-python/LICENSE
          cp LICENSE package-r/LICENSE
      - name: Build test data (Install perpetual with its dev dependencies)
        run: |
          cd package-python
          uv pip install --system -e .[dev]
          cd ..
      - name: Fallback build resources
        if: steps.restore-resources.outputs.cache-hit != 'true'
        run: python scripts/make_resources.py
      - name: Run tests
        # Cargo tests in the Rust package might still need the 'resources' folder
        # to exist and contain the data, which is now guaranteed by the download step.
        run: cargo test --verbose
      - name: Install cargo-tarpaulin
        uses: taiki-e/install-action@cargo-tarpaulin
      - name: Run coverage
        run: cargo tarpaulin --verbose --out Xml
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v5
        with:
          use_oidc: true
          slug: ${{ github.repository }}
          files: ./cobertura.xml
          flags: rust
          fail_ci_if_error: true
          verbose: true

  # 7. R Package Check Job (depends on resources)
  R-CMD-check:
    needs: prepare-resources
    runs-on: ${{ matrix.config.os }}
    name: ${{ matrix.config.os }} (${{ matrix.config.r }})
    strategy:
      fail-fast: false
      matrix:
        config:
          - {os: ubuntu-latest,   r: 'release'}
          - {os: windows-latest,  r: 'release'}

    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
      R_KEEP_PKG_SOURCE: yes
      PERPETUAL_REQ_RESOURCES: true

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Restore resources cache
        id: restore-resources
        uses: actions/cache@v4
        with:
          path: resources
          key: resources-${{ hashFiles('scripts/make_resources.py') }}

      - name: Restore fallback deps (Python) for resource generation
        if: steps.restore-resources.outputs.cache-hit != 'true'
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - name: Install dependencies for resource creation (Fallback)
        if: steps.restore-resources.outputs.cache-hit != 'true'
        run: |
          pip install numpy pandas seaborn scikit-learn toml
          cd package-python
          pip install -e .
          cd ..
      
      - name: Fallback build resources
        if: steps.restore-resources.outputs.cache-hit != 'true'
        run: python scripts/make_resources.py

      - name: Copy Resources for Tests
        run: |
          mkdir -p package-r/tests/testthat/resources
          cp -r resources/* package-r/tests/testthat/resources/
        shell: bash

      - name: Setup Rust
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: nightly
          targets: ${{ runner.os == 'Windows' && 'x86_64-pc-windows-gnu' || '' }}

      - uses: r-lib/actions/setup-r@v2
        with:
          r-version: ${{ matrix.config.r }}
          use-public-rspm: true

      - name: Vendor core Rust logic
        run: python scripts/vendor_r.py

      - uses: r-lib/actions/setup-r-dependencies@v2
        with:
          extra-packages: any::rcmdcheck, any::devtools, any::testthat, any::roxygen2, any::jsonlite, any::covr
          needs: check
          working-directory: package-r

      - name: Generate Documentation
        run: |
          Rscript -e "roxygen2::roxygenise('package-r')"
        shell: bash

      - name: Debug - List files before build
        run: |
          ls -R package-r/src/rust/core | head -n 20
        shell: bash

      - name: Manual Build
        run: |
          R CMD build package-r --no-manual --no-build-vignettes
        shell: bash

      - name: Manual Install Test
        run: |
          tarball=$(ls perpetual_*.tar.gz | head -n 1)
          R CMD INSTALL "$tarball" --no-test-load
        shell: bash

      - name: Dump all check files on failure
        if: failure()
        shell: bash
        run: |
          echo "Listing all files in package-r/check:"
          ls -R package-r/check || true
          echo "Dumping 00install.out if it exists:"
          find . -name "00install.out" -print -exec cat {} \; || true
          echo "Dumping 00check.log if it exists:"
          find . -name "00check.log" -print -exec cat {} \; || true
          echo "Verifying vendored directory:"
          ls -R package-r/src/rust/core || true

      - name: Fix file permissions for R CMD check
        if: runner.os != 'Windows'
        run: |
          # R CMD check warns about executable files in source packages.
          # Strip execute permissions from all source files.
          find package-r/src -type f -exec chmod -x {} +
        shell: bash

      - name: Check
        uses: r-lib/actions/check-r-package@v2
        with:
          working-directory: package-r
          error-on: ${{ runner.os == 'Windows' && '"error"' || '"warning"' }}

      - name: Check Coverage
        if: success() && matrix.config.os == 'ubuntu-latest'
        run: |
           Rscript -e "cov <- covr::package_coverage('package-r'); covr::to_cobertura(cov, filename = 'package-r/cobertura.xml')"
        shell: bash
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v5
        with:
          use_oidc: true
          slug: ${{ github.repository }}
          files: package-r/cobertura.xml
          flags: r
          fail_ci_if_error: true
          verbose: true