Skip to content

Commit

Permalink
fixed qtrees model name; added better error handling in atl24 init sc…
Browse files Browse the repository at this point in the history
…ript
  • Loading branch information
jpswinski committed Nov 14, 2024
1 parent e9a85ba commit 15c8379
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
7 changes: 7 additions & 0 deletions datasets/bathy/extensions/atl24_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@ 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
for _,dir in ipairs({"THU", "TVU"}) do
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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion datasets/bathy/package/BathyFields.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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)
28 changes: 28 additions & 0 deletions packages/core/LuaLibrarySys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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
*----------------------------------------------------------------------------*/
Expand Down
1 change: 1 addition & 0 deletions packages/core/LuaLibrarySys.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 15c8379

Please sign in to comment.