Skip to content

Commit

Permalink
Migrate to pure Julia (#16)
Browse files Browse the repository at this point in the history
* Migrate to pure julia (#15)

* [WIP] remove pycall dependencies

* bump version

* update Sleipnir version

* update dependencies versions to align with Sleipnir

* update CI
  • Loading branch information
albangossard authored Jan 23, 2025
1 parent 1dbbcc1 commit 6ce64d8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 48 deletions.
53 changes: 14 additions & 39 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,14 @@ jobs:
fail-fast: false
matrix:
version:
- '1.9'
python: [3.9]
- '1.11'
os:
- ubuntu-latest
- macos-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- name: Set up Python 🐍 ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Create environment with micromamba 🐍🖤
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: '1.5.6-0'
environment-file: ./environment.yml
environment-name: oggm_env # it is recommendable to add both name and yml file.
init-shell: bash
cache-environment: true
# condarc-file: ./condarc.yml # If necessary, we can include .condarc to configure environment
- name: Test creation of environment with micromamba 🔧🐍🖤
run: |
which python
conda env export
shell: bash -el {0}
- name: Update certifi
run: |
pip install --upgrade certifi
shell: bash -el {0}
# - name: Test OGGM installation 🔧🌎
# run: pytest.oggm
# shell: bash -el {0}
- name: Set ENV Variables for PyCall.jl 🐍 📞
run: export PYTHON=/home/runner/micromamba/envs/oggm_env/bin/python
shell: bash -el {0}
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
Expand All @@ -69,15 +41,18 @@ jobs:
with:
cache-registries: "true"
cache-compiled: "true"
- uses: julia-actions/julia-buildpkg@v1
env:
PYTHON : /home/runner/micromamba/envs/oggm_env/bin/python
# The SSL certificate path can be readed from the action "Check Julia SSL certifications"
SSL_CERT_FILE: /etc/ssl/certs/ca-certificates.crt
- uses: julia-actions/julia-runtest@v1
env:
PYTHON : /home/runner/micromamba/envs/oggm_env/bin/python
SSL_CERT_FILE: /etc/ssl/certs/ca-certificates.crt
- name: Build Julia packages in Ubuntu
uses: julia-actions/julia-buildpkg@v1
if: matrix.os == 'ubuntu-latest'
- name: Build Julia packages in MacOS
uses: julia-actions/julia-buildpkg@v1
if: matrix.os == 'macos-latest'
- name: Run tests in Ubuntu
uses: julia-actions/julia-runtest@v1
if: matrix.os == 'ubuntu-latest'
- name: Run tests in MacOS
uses: julia-actions/julia-runtest@v1
if: matrix.os == 'macos-latest'
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
with:
Expand Down
8 changes: 3 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
name = "Muninn"
uuid = "4b816528-16ba-4e32-9a2e-3c1bc2049d3a"
authors = ["Jordi Bolibar <[email protected]>"]
version = "0.3.0"
version = "0.4.0"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Infiltrator = "5903a43b-9cc3-4c30-8d17-598619ec4e9b"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
Sleipnir = "f5e6c550-199f-11ee-3608-394420200519"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Infiltrator = "1"
Infiltrator = "1.8"
JLD2 = "0.4"
PyCall = "1"
Reexport = "1"
Revise = "3"
Sleipnir = "0.6"
Sleipnir = "0.7.0"
julia = "1.9"

[extras]
Expand Down
1 change: 0 additions & 1 deletion src/Muninn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ using Infiltrator
import Pkg
using Distributed
using Dates
using PyCall

### ODINN.jl dependencies ###
using Reexport
Expand Down
6 changes: 3 additions & 3 deletions src/models/mass_balance/mass_balance_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ end
function MB_timestep(model::Model, glacier::G, step::F, t::F) where {F <: AbstractFloat, G <: AbstractGlacier}
# First we get the dates of the current time and the previous step
period = partial_year(Day, t - step):Day(1):partial_year(Day, t)
climate_step::PyObject = get_cumulative_climate(glacier.climate.sel(time=period))
climate_step::Dict{String, Any} = get_cumulative_climate(glacier.climate[At(period)])
# Convert climate dataset to 2D based on the glacier's DEM
climate_2D_step::PyObject = downscale_2D_climate(climate_step, glacier)
climate_2D_step::Climate2Dstep = downscale_2D_climate(climate_step, glacier)
MB::Matrix{F} = compute_MB(model.mb_model, climate_2D_step)
return MB
end


function MB_timestep!(model::Model, glacier::G, step::F, t; batch_id::Union{Nothing, I} = nothing) where {I <: Integer, F <: AbstractFloat, G <: AbstractGlacier}
# First we get the dates of the current time and the previous step
period = partial_year(Day, t - step):Day(1):partial_year(Day, t)
Expand Down

2 comments on commit 6ce64d8

@albangossard
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

Release notes:

Breaking changes

  • Dependencies to PyCall have been removed. All existing Python objects have been replaced by Julia ones, and hence the interface has changed.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/123585

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.0 -m "<description of version>" 6ce64d856423444c484e005a3446c4eb34a79f0e
git push origin v0.4.0

Please sign in to comment.