Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make 'ml restore' behave the same for broken collections/inconsistent collections #329

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/MT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ function M.getMTfromFile(self,tt)
local f = io.open(tt.fn,"r")
local msg = tt.msg
local collectionName = tt.name
local force = tt.force
if (not f) then
LmodErrorExit()
end
Expand Down Expand Up @@ -1054,8 +1055,8 @@ function M.getMTfromFile(self,tt)
dbg.print{"sn: ",sn,", hash: ", t[sn], "\n"}
end

local force = true
Purge(force)
local forcepurge = true
Purge(forcepurge)

local savedBaseMPATH = l_mt.systemBaseMPATH
dbg.print{"Saved baseMPATH: ",savedBaseMPATH,"\n"}
Expand Down Expand Up @@ -1174,7 +1175,13 @@ function M.getMTfromFile(self,tt)
activeT = nil -- done with activeT
if (#aa > 0) then
sort(aa)
LmodWarning{msg="w_Mods_Not_Loaded",module_list=concatTbl(aa," ")}
if (force ~= true) then
LmodWarning{msg="w_Missing_Coll", collectionName = collectionName, module_list = concatTbl(aa,"\", \"")}
Copy link
Contributor

Choose a reason for hiding this comment

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

why not make this a LmodError if you exit anyway?

LmodErrorExit()
return false
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a change from the current behaviour?

Copy link
Author

Choose a reason for hiding this comment

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

Indeed. And I considered that as a bug, Robert too as it seems :)

else
LmodWarning{msg="w_Missing_Coll_Forced", collectionName = collectionName, module_list = concatTbl(aa,"\", \"")}
end
end

--------------------------------------------------------------------------
Expand All @@ -1191,9 +1198,13 @@ function M.getMTfromFile(self,tt)

if (#aa > 0) then
sort(aa)
LmodWarning{msg="w_Broken_Coll", collectionName = collectionName, module_list = concatTbl(aa,"\", \"")}
if (collectionName ~= "default") then
LmodErrorExit()
if (force ~= true) then
LmodWarning{msg="w_Broken_Coll", collectionName = collectionName, module_list = concatTbl(aa,"\", \"")}
if (collectionName ~= "default") then
LmodErrorExit()
end
else
LmodWarning{msg="w_Broken_Coll_Forced", collectionName = collectionName, module_list = concatTbl(aa,"\", \"")}
end
return false
end
Expand Down
42 changes: 42 additions & 0 deletions src/MessageT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,26 @@ Please submit a consulting ticket if you require additional assistance.
-- LmodWarnings
--------------------------------------------------------------------------
w_Broken_Coll = [==[One or more modules in your %{collectionName} collection have changed: "%{module_list}".

To see the contents of this collection do:
$ module describe %{collectionName}
To forcibly load this collection without the changed modules do:
$ module restore %{collectionName} --force
To rebuild the collection, load the modules you wish then do:
$ module save %{collectionName}
If you no longer want this module collection do:
$ rm ~/.lmod.d/%{collectionName}

For more information execute 'module help' or see http://lmod.readthedocs.org/
No change in modules loaded

]==],
w_Missing_Coll = [==[One or more modules in your %{collectionName} collection are missing: "%{module_list}".

To see the contents of this collection do:
$ module describe %{collectionName}
To forcibly load this collection without the missing modules do:
$ module restore %{collectionName} --force
To rebuild the collection, load the modules you wish then do:
$ module save %{collectionName}
If you no longer want this module collection do:
Expand All @@ -60,6 +78,30 @@ If you no longer want this module collection do:
For more information execute 'module help' or see http://lmod.readthedocs.org/
No change in modules loaded

]==],
w_Broken_Coll_Forced = [==[Forcibly loading collection %{collectionName} despite changed modules: "%{module_list}".

To see the contents of this collection do:
$ module describe %{collectionName}
To rebuild the collection, load the modules you wish then do:
$ module save %{collectionName}
If you no longer want this module collection do:
$ rm ~/.lmod.d/%{collectionName}

For more information execute 'module help' or see http://lmod.readthedocs.org/

]==],
w_Missing_Coll_Forced = [==[Forcibly loading collection %{collectionName} despite missing modules: "%{module_list}".

To see the contents of this collection do:
$ module describe %{collectionName}
To rebuild the collection, load the modules you wish then do:
$ module save %{collectionName}
If you no longer want this module collection do:
$ rm ~/.lmod.d/%{collectionName}

For more information execute 'module help' or see http://lmod.readthedocs.org/

]==],
w_Broken_FullName = "Badly formed module-version line: module-name must be fully qualified: %{fullName} is not\n",
w_MPATH_Coll = "The system MODULEPATH has changed: Please rebuild your saved collection.\n",
Expand Down
10 changes: 8 additions & 2 deletions src/cmdfuncs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ end
-- state. If a user has a "default" then use that collection.
-- Otherwise do a "Reset()"
-- @param collection The user supplied collection name. If *nil* the use "default"
function Restore(collection)
function Restore(collection, force)
Copy link
Contributor

Choose a reason for hiding this comment

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

add any new arguments to the doc string of the function.

dbg.start{"Restore(",collection,")"}

local msg
Expand Down Expand Up @@ -565,6 +565,12 @@ function Restore(collection)


local masterTbl = masterTbl()
local force
if (masterTbl.force) then
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the point of this?

local force = masterTbl.force

does the same? And if you only need to pass it as an argument, do you really need a local variable?

force = true
else
force = false
end

if (collection == "system" ) then
msg = "system default" .. msgTail
Expand All @@ -581,7 +587,7 @@ function Restore(collection)
Reset(msg)
else
local mt = FrameStk:singleton():mt()
local results = mt:getMTfromFile{fn=path, name=myName, msg=msg}
local results = mt:getMTfromFile{fn=path, name=myName, msg=msg, force=force}
if (not results and collection == "default") then
Reset(msg)
end
Expand Down