Skip to content

Commit

Permalink
File based checkpointing and other oddities
Browse files Browse the repository at this point in the history
  • Loading branch information
moeyensj committed Jan 17, 2025
1 parent ebbbbf8 commit 1bbc40b
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 48 deletions.
61 changes: 46 additions & 15 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies = [
"sorcha @ git+https://github.com/B612-Asteroid-Institute/sorcha.git@cd5be9a06c6d24e1277cf2345bda9984f7097ede",
"adam-core>=0.3.5",
"quivr @ git+https://github.com/B612-Asteroid-Institute/quivr@2d8ae0b40bdfb75bcceff0c73d41a52d4bffb5dc",
"ipdb>=0.13.13",
]
requires-python = "<3.13,>=3.11"
readme = "README.md"
Expand Down
2 changes: 2 additions & 0 deletions src/adam_impact_study/analysis/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,3 +544,5 @@ def summarize_impact_study_results(

if plot:
make_analysis_plots(results, out_dir)

return results
11 changes: 10 additions & 1 deletion src/adam_impact_study/cli/impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pyarrow.compute as pc
from adam_core.time import Timestamp

from adam_impact_study.analysis import plot_ip_over_time
from adam_impact_study.analysis.main import plot_ip_over_time
from adam_impact_study.impacts_study import run_impact_study_all
from adam_impact_study.types import ImpactorOrbits, RunConfiguration

Expand All @@ -24,6 +24,7 @@ def run_impact_study(
run_config: RunConfiguration,
pointing_file: Optional[str] = None,
orbit_id_filter: Optional[str] = None,
overwrite: bool = False,
) -> None:
"""Run impact study on provided orbits."""
# Load orbits directly from parquet
Expand Down Expand Up @@ -84,6 +85,7 @@ def run_impact_study(
monte_carlo_samples=run_config.monte_carlo_samples,
max_processes=run_config.max_processes,
seed=run_config.seed,
overwrite=overwrite,
)

logger.info("Generating plots...")
Expand Down Expand Up @@ -115,6 +117,12 @@ def main():
"--orbit-id-filter",
help="Comma-delimited list of substrings to filter orbit id by",
)
parser.add_argument(
"--overwrite",
action="store_true",
help="Overwrite existing results in run directory",
default=False,
)
parser.add_argument("--debug", action="store_true", help="Enable debug logging")

args = parser.parse_args()
Expand Down Expand Up @@ -154,6 +162,7 @@ def main():
run_config=run_config,
pointing_file=args.pointing_file,
orbit_id_filter=args.orbit_id_filter,
overwrite=args.overwrite,
)


Expand Down
8 changes: 5 additions & 3 deletions src/adam_impact_study/fo_od.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def _create_fo_tmp_directory() -> str:
Returns:
str: The absolute path to the temporary directory populated with necessary FO files
"""
base_tmp_dir = os.path.expanduser("~/.cache/adam_impact_study/ftmp")
base_tmp_dir = os.path.expanduser("~/.cache/adam_impact_study/")
os.makedirs(base_tmp_dir, mode=0o770, exist_ok=True)
tmp_dir = tempfile.mkdtemp(dir=base_tmp_dir)
tmp_dir = tempfile.mkdtemp(dir=base_tmp_dir, prefix="fo_")
os.chmod(tmp_dir, 0o770)
tmp_dir = _populate_fo_directory(tmp_dir)
return tmp_dir
Expand Down Expand Up @@ -186,7 +186,9 @@ def run_fo_od(
shutil.rmtree(fo_tmp_dir)

if result.returncode != 0:
logger.warning(f"Find_Orb failed with return code {result.returncode}")
logger.warning(
f"Find_Orb failed with return code {result.returncode} for {len(observations)} observations in {fo_result_dir}"
)
logger.warning(f"{result.stdout}\n{result.stderr}")
return Orbits.empty(), ADESObservations.empty(), "Find_Orb failed"

Expand Down
Loading

0 comments on commit 1bbc40b

Please sign in to comment.