From ca11db33f3225f63b8ba0b190ff81fe5a36a8923 Mon Sep 17 00:00:00 2001 From: Dar Dahlen Date: Thu, 18 Jul 2024 10:24:11 -0700 Subject: [PATCH] Add GIT LFS support (#80) * add LFS support, starting with MPC Orb file * doc actions tweaked to make use of this * updated an example so that it used this file instead of comets --- .gitattributes | 1 + .github/workflows/docs.yml | 70 ---------------------------- .github/workflows/release-wheels.yml | 2 +- .github/workflows/test-lint.yml | 56 ++++++++++++++++++++-- Cargo.toml | 3 +- docs/data/mpcorb_extended.json.gz | 3 ++ src/examples/plot_mpc_state.py | 29 ++++++------ 7 files changed, 73 insertions(+), 91 deletions(-) create mode 100644 .gitattributes delete mode 100644 .github/workflows/docs.yml create mode 100644 docs/data/mpcorb_extended.json.gz diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..b9c4a68 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +docs/data/mpcorb_extended.json.gz filter=lfs diff=lfs merge=lfs -text diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 719a8a0..0000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,70 +0,0 @@ -# This workflow will install Python dependencies, run tests, lint, and build docs -# This run for every pull request - -name: Build Docs - -on: - push: - branches: [ "main" ] -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true -jobs: - build: - runs-on: ubuntu-latest - timeout-minutes: 10 - strategy: - fail-fast: false - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.9" - - name: Install dependencies - run: | - python3 -m pip install --upgrade pip setuptools - - name: Build neospy - run: | - python3 -m pip install '.[dev]' -v - - name: Build Docs - run: | - (cd docs && make clean && make html && make doctest) - - name: Fix permissions - run: | - chmod -c -R +rX "docs/" | while read line; do - echo "::warning title=Invalid file permissions automatically fixed::$line" - done - # - name: Archive Docs - # uses: actions/upload-artifact@v2 - # with: - # name: "github-pages" - # path: - # docs/html/* - - name: Upload Pages artifact - uses: actions/upload-pages-artifact@v3 - with: - name: "github-pages" - path: - docs/html/ - - deploy: - # Add a dependency to the build job - needs: build - - # Grant GITHUB_TOKEN the permissions required to make a Pages deployment - permissions: - pages: write # to deploy to Pages - id-token: write # to verify the deployment originates from an appropriate source - - # Deploy to the github-pages environment - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - - # Specify runner + deployment step - runs-on: ubuntu-latest - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 diff --git a/.github/workflows/release-wheels.yml b/.github/workflows/release-wheels.yml index c2019f6..b17510e 100644 --- a/.github/workflows/release-wheels.yml +++ b/.github/workflows/release-wheels.yml @@ -45,7 +45,7 @@ jobs: python: 311 platform_id: macosx_arm64 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Rust uses: dtolnay/rust-toolchain@stable - run: cargo test --all-features diff --git a/.github/workflows/test-lint.yml b/.github/workflows/test-lint.yml index e6517ff..577c5f9 100644 --- a/.github/workflows/test-lint.yml +++ b/.github/workflows/test-lint.yml @@ -8,9 +8,14 @@ on: branches: [ "main" ] pull_request: branches: [ "main" ] + +env: + NEOSPY_CACHE_DIR: ${{ github.workspace }}/docs/data + concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true + jobs: build: timeout-minutes: 10 @@ -18,11 +23,16 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + lfs: true - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.9" + - name: Test with cargo + run: | + cargo test - name: Install dependencies run: | python3 -m pip install --upgrade pip setuptools black mypy types-requests numpy @@ -32,12 +42,52 @@ jobs: - name: Lint with mypy run: | python3 -m mypy src/neospy/ + + # Build and run pytest - name: Build neospy run: | python3 -m pip install '.[dev]' -v - name: Test with pytest run: | python3 -m pytest --cov-report term-missing --cov=neospy - - name: Test with cargo + + # Build documentation and push artifact + - name: Build Docs run: | - cargo test \ No newline at end of file + cd docs + make clean + make doctest + make html + - name: Fix permissions + run: | + chmod -c -R +rX "docs/" | while read line; do + echo "::warning title=Invalid file permissions automatically fixed::$line" + done + - name: Upload Docs artifact + uses: actions/upload-artifact@master + with: + name: "github-pages" + path: + docs/html/ + + + deploy: + needs: build + if: success() && github.ref == 'refs/heads/main' + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + # Specify runner + deployment step + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index b5301af..06c5047 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,5 +28,4 @@ members = ["src/neospy_core"] default-members = ["src/neospy_core"] [profile.release] -opt-level = 3 -pyo3_disable_reference_pool = true \ No newline at end of file +opt-level = 3 \ No newline at end of file diff --git a/docs/data/mpcorb_extended.json.gz b/docs/data/mpcorb_extended.json.gz new file mode 100644 index 0000000..bd7dccb --- /dev/null +++ b/docs/data/mpcorb_extended.json.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:98c26b8905f870ceb3157700ca85c6131c6dbdcaec3cb4662bfa8435709f3526 +size 158863150 diff --git a/src/examples/plot_mpc_state.py b/src/examples/plot_mpc_state.py index 2e2a45a..c069581 100644 --- a/src/examples/plot_mpc_state.py +++ b/src/examples/plot_mpc_state.py @@ -4,7 +4,7 @@ This will open an interactive 3d plot of the solar system. -This plots all comets from the MPC, along with the last 365 days of their orbit. +This plots all of the Hildas from the MPC, along with the last 90 days of their orbit. """ import neospy @@ -12,20 +12,22 @@ import numpy as np # Set the X/Y/Z scale -zoom = 4 +zoom = 4.0 -# Fetch all known comet orbits -orb = neospy.mpc.fetch_known_comet_orbit_data() +# Fetch all known asteroid orbits +orb = neospy.mpc.fetch_known_orbit_data() + +# Subset to the Hildas +orb = orb[orb["group_name"] == "Hilda"] + +# convert the table of data to State objects +states = neospy.mpc.table_to_states(orb) # Every object in the MPC orbit file has its own epoch of fit. # This means that some objects epochs may be months or years away from # others. In order to bring all of these objects to the same epoch, the -# function below finds the most common epoch in the data, and uses n-body -# integration to calculate the position of all objects that the median -# epoch. If all known objects are included, then this may take a little -# while to compute. -states = neospy.mpc.table_to_states(orb) - +# function below will propagate the states to the first state's epoch. +states = neospy.propagate_two_body(states, states[0].jd) # Grab the positions from this subset pos = np.array([p.pos for p in states]) @@ -46,13 +48,10 @@ ax.plot(pos[0], pos[1], pos[2], color="black", alpha=0.2) for state in states: - # Skip fragments - if " " in state.desig: - continue jd = states[0].jd - jds = np.linspace(jd - 365, jd, 100) + jds = np.linspace(jd - 90, jd, 100) pos = np.array([neospy.propagate_two_body([state], jd)[0].pos for jd in jds]).T - ax.plot(pos[0], pos[1], pos[2], color="black", alpha=0.2, lw=0.2) + ax.plot(pos[0], pos[1], pos[2], color="black", alpha=0.1, lw=0.2) ax.scatter(0, 0, 0, color="red") ax.set_xticks([-zoom, 0, zoom])