From 15c8379b696bc28e722248117ea6067d236bb57f Mon Sep 17 00:00:00 2001 From: JP Swinski Date: Thu, 14 Nov 2024 16:51:14 +0000 Subject: [PATCH] fixed qtrees model name; added better error handling in atl24 init script --- datasets/bathy/extensions/atl24_init.lua | 7 +++++ datasets/bathy/package/BathyFields.h | 2 +- ...{release-v4-8-12.md => release-v4-8-13.md} | 8 +++--- packages/core/LuaLibrarySys.cpp | 28 +++++++++++++++++++ packages/core/LuaLibrarySys.h | 1 + 5 files changed, 41 insertions(+), 5 deletions(-) rename docs/rtd/source/release_notes/{release-v4-8-12.md => release-v4-8-13.md} (84%) diff --git a/datasets/bathy/extensions/atl24_init.lua b/datasets/bathy/extensions/atl24_init.lua index 8cd4f2a1c..4c5d03508 100644 --- a/datasets/bathy/extensions/atl24_init.lua +++ b/datasets/bathy/extensions/atl24_init.lua @@ -29,11 +29,13 @@ while sys.alive() and ( (not bathy_mask_complete) or local bathy_mask_local = cre.HOST_DIRECTORY.."/ATL24_Mask_v5_Raster.tif" local bathy_mask_remote = "config/ATL24_Mask_v5_Raster.tif" bathy_mask_complete = sys.fileexists(bathy_mask_local) or aws.s3download("sliderule", bathy_mask_remote, aws.DEFAULT_REGION, aws.DEFAULT_IDENTITY, bathy_mask_local) + if not bathy_mask_complete then sys.deletefile(bathy_mask_local) end -- water ri mask local water_ri_mask_local = cre.HOST_DIRECTORY.."/cop_rep_ANNUAL_meanRI_d00.tif" local water_ri_mask_remote = "config/cop_rep_ANNUAL_meanRI_d00.tif" water_ri_mask_complete = sys.fileexists(water_ri_mask_local) or aws.s3download("sliderule", water_ri_mask_remote, aws.DEFAULT_REGION, aws.DEFAULT_IDENTITY, water_ri_mask_local) + if not water_ri_mask_complete then sys.deletefile(water_ri_mask_local) end -- uncertainty lookup table for deg = 0,5 do @@ -41,6 +43,7 @@ while sys.alive() and ( (not bathy_mask_complete) or local uncertainty_lut_local = string.format("%s/ICESat2_%ddeg_500000_AGL_0.022_mrad_%s.csv", cre.HOST_DIRECTORY, deg, dir) local uncertainty_lut_remote = string.format("config/ICESat2_%ddeg_500000_AGL_0.022_mrad_%s.csv", deg, dir) local uncertainty_lut_status = sys.fileexists(uncertainty_lut_local) or aws.s3download("sliderule", uncertainty_lut_remote, aws.DEFAULT_REGION, aws.DEFAULT_IDENTITY, uncertainty_lut_local) + if not uncertainty_lut_status then sys.deletefile(uncertainty_lut_local) end uncertainty_lut_complete = uncertainty_lut_complete and uncertainty_lut_status end end @@ -49,21 +52,25 @@ while sys.alive() and ( (not bathy_mask_complete) or local pointnet_model_local = cre.HOST_DIRECTORY.."/"..bathy.POINTNET_MODEL local pointnet_model_remote = "config/"..bathy.POINTNET_MODEL pointnet_model_complete = sys.fileexists(pointnet_model_local) or aws.s3download("sliderule", pointnet_model_remote, aws.DEFAULT_REGION, aws.DEFAULT_IDENTITY, pointnet_model_local) + if not pointnet_model_complete then sys.deletefile(pointnet_model_local) end -- qtrees model local qtrees_model_local = cre.HOST_DIRECTORY.."/"..bathy.QTREES_MODEL local qtrees_model_remote = "config/"..bathy.QTREES_MODEL qtrees_model_complete = sys.fileexists(qtrees_model_local) or aws.s3download("sliderule", qtrees_model_remote, aws.DEFAULT_REGION, aws.DEFAULT_IDENTITY, qtrees_model_local) + if not qtrees_model_complete then sys.deletefile(qtrees_model_local) end -- coastnet model local coastnet_model_local = cre.HOST_DIRECTORY.."/"..bathy.COASTNET_MODEL local coastnet_model_remote = "config/"..bathy.COASTNET_MODEL coastnet_model_complete = sys.fileexists(coastnet_model_local) or aws.s3download("sliderule", coastnet_model_remote, aws.DEFAULT_REGION, aws.DEFAULT_IDENTITY, coastnet_model_local) + if not coastnet_model_complete then sys.deletefile(coastnet_model_local) end -- ensemble model local ensemble_model_local = cre.HOST_DIRECTORY.."/"..bathy.ENSEMBLE_MODEL local ensemble_model_remote = "config/"..bathy.ENSEMBLE_MODEL ensemble_model_complete = sys.fileexists(ensemble_model_local) or aws.s3download("sliderule", ensemble_model_remote, aws.DEFAULT_REGION, aws.DEFAULT_IDENTITY, ensemble_model_local) + if not ensemble_model_complete then sys.deletefile(ensemble_model_local) end -- check for completeness if (not bathy_mask_complete) or diff --git a/datasets/bathy/package/BathyFields.h b/datasets/bathy/package/BathyFields.h index cb40d9156..32382d9db 100644 --- a/datasets/bathy/package/BathyFields.h +++ b/datasets/bathy/package/BathyFields.h @@ -46,7 +46,7 @@ ******************************************************************************/ #define COASTNET_MODEL "coastnet_model-20241111.json" -#define QTREES_MODEL "qtrees_model-20241104.json" +#define QTREES_MODEL "qtrees_model-20241105.json" #define ENSEMBLE_MODEL "ensemble_model-20241030.json" #define POINTNET_MODEL "pointnet2_model.pth" diff --git a/docs/rtd/source/release_notes/release-v4-8-12.md b/docs/rtd/source/release_notes/release-v4-8-13.md similarity index 84% rename from docs/rtd/source/release_notes/release-v4-8-12.md rename to docs/rtd/source/release_notes/release-v4-8-13.md index 8f209bcc0..c426831e8 100644 --- a/docs/rtd/source/release_notes/release-v4-8-12.md +++ b/docs/rtd/source/release_notes/release-v4-8-13.md @@ -1,8 +1,8 @@ -# Release v4.8.12 +# Release v4.8.13 -2024-11-13 +2024-11-14 -Version description of the v4.8.12 release of SlideRule Earth. +Version description of the v4.8.13 release of SlideRule Earth. Bathy Version #12. @@ -16,4 +16,4 @@ Bathy Version #12. ## Getting This Release -[https://github.com/SlideRuleEarth/sliderule/releases/tag/v4.8.12](https://github.com/SlideRuleEarth/sliderule/releases/tag/v4.8.12) +[https://github.com/SlideRuleEarth/sliderule/releases/tag/v4.8.13](https://github.com/SlideRuleEarth/sliderule/releases/tag/v4.8.13) diff --git a/packages/core/LuaLibrarySys.cpp b/packages/core/LuaLibrarySys.cpp index 6830be9b5..71d174722 100644 --- a/packages/core/LuaLibrarySys.cpp +++ b/packages/core/LuaLibrarySys.cpp @@ -75,6 +75,7 @@ const struct luaL_Reg LuaLibrarySys::sysLibs [] = { {"lsobj", LuaLibrarySys::lsys_lsobj}, {"cwd", LuaLibrarySys::lsys_cwd}, {"fileexists", LuaLibrarySys::lsys_fileexists}, + {"deletefile", LuaLibrarySys::lsys_deletefile}, {"memu", LuaLibrarySys::lsys_memu}, {"setmemlimit", LuaLibrarySys::lsys_setmemlimit}, {"lsdev", DeviceObject::luaList}, @@ -618,6 +619,33 @@ int LuaLibrarySys::lsys_fileexists (lua_State* L) return 1; } +/*---------------------------------------------------------------------------- + * lsys_deletefile - deletes file it it exists + *----------------------------------------------------------------------------*/ +int LuaLibrarySys::lsys_deletefile (lua_State* L) +{ + bool status = false; + if(lua_isstring(L, 1)) + { + const char* filename = lua_tostring(L, 1); + if(std::filesystem::exists(filename)) + { + const int rc = std::remove(filename); + if(rc == 0) + { + status = true; + } + else + { + char err_buf[256]; + mlog(CRITICAL, "Failed (%d) to delete file %s: %s", rc, filename, strerror_r(errno, err_buf, sizeof(err_buf))); // Get thread-safe error message + } + } + } + lua_pushboolean(L, status); + return 1; +} + /*---------------------------------------------------------------------------- * lsys_memu - memory usage *----------------------------------------------------------------------------*/ diff --git a/packages/core/LuaLibrarySys.h b/packages/core/LuaLibrarySys.h index 20f76835d..8d7b7dc75 100644 --- a/packages/core/LuaLibrarySys.h +++ b/packages/core/LuaLibrarySys.h @@ -94,6 +94,7 @@ class LuaLibrarySys static int lsys_lsobj (lua_State* L); static int lsys_cwd (lua_State* L); static int lsys_fileexists (lua_State* L); + static int lsys_deletefile (lua_State* L); static int lsys_memu (lua_State* L); static int lsys_setmemlimit (lua_State* L);