Skip to content

Commit a559660

Browse files
committed
Merge branch 'release/0.23.0.1' into release_update
# Conflicts: # recipe.yaml
2 parents 24027d8 + 7d2fddc commit a559660

12 files changed

Lines changed: 114 additions & 37 deletions

File tree

.github/workflows/issue_to_jira.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ on:
44
issues:
55
types: [opened]
66

7+
permissions:
8+
contents: read
9+
issues: write
10+
711
jobs:
812
call-workflow-create-jira-issue:
913
uses: MiraGeoscience/CI-tools/.github/workflows/reusable-jira-issue_to_jira.yml@main
10-
secrets: inherit
1114
with:
1215
project-key: 'GEOPY'
1316
components: '[{"name": "simpeg"}]'
17+
secrets:
18+
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
19+
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
20+
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
name: Add JIRA issue summary
22

33
on:
4-
pull_request_target:
4+
pull_request_target: # zizmor: ignore[dangerous-triggers]
55
types: [opened]
66

7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
711
jobs:
812
call-workflow-add-jira-issue-summary:
913
uses: MiraGeoscience/CI-tools/.github/workflows/reusable-jira-pr_add_jira_summary.yml@main
10-
secrets: inherit
14+
secrets:
15+
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
16+
JIRA_BASIC_AUTH: ${{ secrets.JIRA_BASIC_AUTH }}

.github/workflows/pull_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
persist-credentials: false
6969

7070
- name: flake8 review
71-
uses: reviewdog/action-flake8@v3
71+
uses: reviewdog/action-flake8@b65981e158319f08cb7d0132f28bc0081e110adc # v3.15.2
7272
with:
7373
workdir: pr_source
7474
github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -104,7 +104,7 @@ jobs:
104104
path: 'pr_source'
105105
persist-credentials: false
106106

107-
- uses: reviewdog/action-black@v3
107+
- uses: reviewdog/action-black@644053a260402bc4278a865906107bd8aef7fae8 # v3.22.4
108108
with:
109109
workdir: 'pr_source'
110110
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/python_deploy_dev.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ jobs:
1313
call-workflow-conda-publish:
1414
name: Publish development conda package on JFrog Artifactory
1515
uses: MiraGeoscience/CI-tools/.github/workflows/reusable-python-publish_rattler_package.yml@main
16+
permissions:
17+
contents: write # to create draft release and attach artifacts
18+
actions: read
1619
with:
1720
package-name: 'mira-simpeg'
1821
python-version: '3.10'
@@ -25,6 +28,9 @@ jobs:
2528
call-workflow-pypi-publish:
2629
name: Publish development pypi package (JFrog Artifactory, TestPyPI)
2730
uses: MiraGeoscience/CI-tools/.github/workflows/reusable-python-publish_pypi_package.yml@main
31+
permissions:
32+
contents: write # to create draft release and attach artifacts
33+
actions: read
2834
with:
2935
package-manager: 'setuptools'
3036
package-name: 'mira-simpeg'

.github/workflows/python_deploy_prod.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ jobs:
2828
name: Publish production Conda package on JFrog Artifactory
2929
if: ${{ github.event_name == 'release' || github.event.inputs.publish-conda == 'true' }}
3030
uses: MiraGeoscience/CI-tools/.github/workflows/reusable-python-release_conda_assets.yml@main
31+
permissions:
32+
contents: write # seems required to find the draft release
33+
actions: read
3134
with:
32-
virtual-repo-names: '["public-conda-prod"]'
35+
virtual-repo-names: '["public-noremote-conda-prod"]'
3336
release-tag: ${{ github.event.release.tag_name || github.event.inputs.release-tag }}
3437
secrets:
3538
JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }}
@@ -38,6 +41,9 @@ jobs:
3841
name: Publish production PyPI package (JFrog Artifactory, PyPI)
3942
if: ${{ github.event_name == 'release' || github.event.inputs.publish-pypi == 'true' }}
4043
uses: MiraGeoscience/CI-tools/.github/workflows/reusable-python-release_pypi_assets.yml@main
44+
permissions:
45+
contents: write # seems required to find the draft release
46+
actions: read
4147
with:
4248
package-name: 'mira-simpeg'
4349
virtual-repo-names: '["public-pypi-prod", "pypi"]'

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ classifiers = [
3535
"Topic :: Scientific/Engineering",
3636
"Topic :: Scientific/Engineering :: Mathematics",
3737
"Topic :: Scientific/Engineering :: Physics",
38+
"Topic :: Software Development :: Libraries :: Python Modules",
3839
"Operating System :: Microsoft :: Windows",
3940
"Operating System :: POSIX",
4041
"Operating System :: Unix",

simpeg/dask/electromagnetics/time_domain/simulation.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from dask import array, delayed
1212
from dask.distributed import get_client
1313

14+
from time import time
1415
from simpeg.dask.utils import get_parallel_blocks
1516
from simpeg.utils import mkvc
1617

@@ -405,10 +406,6 @@ def get_field_deriv_block(
405406
# Cut out early data
406407
time_check = np.kron(time_mask, np.ones(shape, dtype=bool))[rx_ind]
407408
local_ind = np.arange(rx_ind.shape[0])[time_check]
408-
409-
if len(local_ind) < 1:
410-
continue
411-
412409
indices.append(
413410
(np.arange(count, count + len(local_ind)), local_ind),
414411
)
@@ -425,14 +422,14 @@ def get_field_deriv_block(
425422

426423
stacked_blocks.append(stacked_block)
427424

428-
if len(stacked_blocks) > 0:
429-
blocks = np.hstack(stacked_blocks)
430-
425+
blocks = np.hstack(stacked_blocks)
426+
if blocks.ndim == 2 and blocks.shape[1] > 0:
431427
solve = (AdiagTinv * blocks).reshape(blocks.shape)
432428
else:
433429
solve = None
434430

435431
updated_ATinv_df_duT_v = []
432+
436433
for (_, arrays), field_deriv, ATinv_chunk, (columns, local_ind) in zip(
437434
block, field_derivs, ATinv_df_duT_v, indices, strict=True
438435
):
@@ -444,10 +441,9 @@ def get_field_deriv_block(
444441
)
445442
ATinv_chunk = np.zeros(shape, dtype=np.float32)
446443

447-
if solve is None:
448-
continue
444+
if solve is not None:
445+
ATinv_chunk[:, local_ind] = solve[:, columns]
449446

450-
ATinv_chunk[:, local_ind] = solve[:, columns]
451447
updated_ATinv_df_duT_v.append(ATinv_chunk)
452448

453449
return updated_ATinv_df_duT_v

simpeg/dask/objective_function.py

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ def _calc_dpred(objfct, _):
1515
return objfct.simulation.dpred(m=objfct.simulation.model)
1616

1717

18+
def _calc_objective(objfct, multiplier, model):
19+
return multiplier * objfct(model)
20+
21+
1822
def _calc_residual(objfct, _):
1923
return objfct.W * (
2024
objfct.data.dobs - objfct.simulation.dpred(m=objfct.simulation.model)
@@ -33,6 +37,18 @@ def _store_model(objfct, model):
3337
objfct.simulation.model = model
3438

3539

40+
def _setter_broadcast(objfct, key, value):
41+
"""
42+
Broadcast a value to all workers.
43+
"""
44+
if hasattr(objfct, key):
45+
setattr(objfct, key, value)
46+
47+
for sim in objfct.simulation.simulations:
48+
if hasattr(sim, key):
49+
setattr(sim, key, value)
50+
51+
3652
def _get_jtj_diag(objfct, _):
3753
jtj = objfct.simulation.getJtJdiag(objfct.simulation.model, objfct.W)
3854
return jtj.flatten()
@@ -56,14 +72,15 @@ def _validate_type_or_future_of_type(
5672
property_name, objects, obj_type, ensure_unique=True
5773
)
5874
workload = [[]]
75+
lookup = {}
5976
count = 0
6077
for obj in objects:
6178
if count == len(workers):
6279
count = 0
6380
workload.append([])
6481
obj.simulation.simulations[0].worker = workers[count]
6582
future = client.scatter([obj], workers=workers[count])[0]
66-
83+
lookup[obj] = (future, workers[count])
6784
if hasattr(obj, "name"):
6885
future.name = obj.name
6986

@@ -84,7 +101,7 @@ def _validate_type_or_future_of_type(
84101
raise TypeError(f"{property_name} futures must be an instance of {obj_type}")
85102

86103
if return_workers:
87-
return workload, workers
104+
return workload, workers, lookup
88105
else:
89106
return workload
90107

@@ -374,7 +391,7 @@ def objfcts(self):
374391
def objfcts(self, objfcts):
375392
client = self.client
376393

377-
futures, workers = _validate_type_or_future_of_type(
394+
futures, workers, lookup = _validate_type_or_future_of_type(
378395
"objfcts",
379396
objfcts,
380397
L2DataMisfit,
@@ -387,6 +404,11 @@ def objfcts(self, objfcts):
387404
self._futures = futures
388405
self._workers = workers
389406

407+
self._lookup = {
408+
misfit.simulation: (future, worker)
409+
for misfit, (future, worker) in lookup.items()
410+
}
411+
390412
def residuals(self, m, f=None):
391413
"""
392414
Compute the residual for the data misfit.
@@ -411,3 +433,26 @@ def residuals(self, m, f=None):
411433
residuals += client.gather(future_residuals)
412434

413435
return residuals
436+
437+
def broadcast_updates(self, updates: dict):
438+
"""
439+
Set the attributes of the objective functions and simulations
440+
"""
441+
stores = []
442+
client = self.client
443+
for fun, (key, value) in updates.items():
444+
if fun not in self._lookup:
445+
continue
446+
447+
future, worker = self._lookup[fun]
448+
449+
stores.append(
450+
client.submit(
451+
_setter_broadcast,
452+
future,
453+
key,
454+
value,
455+
workers=worker,
456+
)
457+
)
458+
self.client.gather(stores) # blocking call to ensure all models were stored

simpeg/directives/_regularization.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,19 +229,20 @@ def adjust_cooling_schedule(self):
229229
"""
230230
Adjust the cooling schedule based on the misfit.
231231
"""
232-
ratio = self.invProb.phi_d / self.misfit_from_chi_factor(self.chifact_target)
232+
if self.metrics.start_irls_iter is None:
233+
return
233234

234-
if (
235-
np.abs(1.0 - ratio) > self.misfit_tolerance
236-
and self.metrics.start_irls_iter is not None
237-
):
235+
ratio = self.invProb.phi_d / self.misfit_from_chi_factor(self.chifact_target)
236+
if np.abs(1.0 - ratio) > self.misfit_tolerance:
238237

239238
if ratio > 1:
240-
ratio = np.mean([2.0, ratio])
239+
update_ratio = 1 / np.mean([0.75, 1 / ratio])
241240
else:
242-
ratio = np.mean([0.75, ratio])
241+
update_ratio = 1 / np.mean([2.0, 1 / ratio])
243242

244-
self.cooling_factor = ratio
243+
self.cooling_factor = update_ratio
244+
else:
245+
self.cooling_factor = 1.0
245246

246247
def initialize(self):
247248
"""

simpeg/directives/_save_geoh5.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,7 @@ def write(self, iteration: int, **_):
379379
with open(dirpath / "SimPEG.log", "r", encoding="utf-8") as file:
380380
iteration = 0
381381
for line in file:
382-
val = re.findall(
383-
"[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)", line # noqa
384-
)
382+
val = re.findall(r"[+-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+-]?\d+)", line)
385383
if len(val) == 5:
386384
log.append(val[:-2])
387385
iteration += 1

0 commit comments

Comments
 (0)