You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some GAMS programs have a delicate directory structure, and the main file might not be in the root folder of the project. In case of Balmorel, the project is structured as follows (not all files are show):
Balmorel
├───base
│ ├───addons
│ ├───auxils
│ ├───bui
│ ├───data
| | (this folder has the input data files)
│ ├───documentation
│ ├───logerror
│ │ └───logerinc
│ ├───model
| | Balmorel.gms *This is the main file*
│ └───output
│ ├───economic
│ ├───inputout
│ ├───printout
│ │ └───printinc
│ └───temp
└───simex
Setting this up using the Toolbox interface is possible, but problems start when trying to execute in a work folder. Toolbox takes the folder Balmorel/base/model as the main_dir and copies everything from there into a temporary work directory root (i.e. something like /balmorel__xxxxxxxxxxxxxxxxxx__toolbox). But some files and the data should be outside of this folder and on the same or above level in hierarchy, so they end up in wrong places and the GAMS program does not find them.
My work-around
My temporary solution is to edit the tool specification file by hand to list the source files like this:
The specification file is stored in the Toolbox project folder alongside with the directory Balmorel which has the source code. Now files are copied into their right places into a temp working dir.
GAMS needs to have the current dir set to where the main program file is located. Toolbox does that by setting the CurDir GAMS command line argument. I’ve made the following change to make this work:
--- a/spinetoolbox/tool_specifications.py+++ b/spinetoolbox/tool_specifications.py@@ -400,7 +400,7 @@ class GAMSTool(ToolSpecification):
Args:
basedir (str): the path to the directory where the instance will run
"""
- return GAMSToolInstance(self, basedir, self._settings, self._logger)+ return GAMSToolInstance(self, os.path.join(basedir, self.main_dir), self._settings, self._logger)
This will now pass the temp workdir (basedir) joined with the main dir (self.main_dir) to the CurDir argument. Something like this:
Change the main file selection in the Tool spec. editor into source code folder selector. In the above case that would be folder Balmorel. In addition we need a main file selection box, to set the main program file explicitly, and it will be stored as relative to the source code folder. Other source files will be relative to that folder too.
Benefit: This would probably allow extending (easily?) to support Git repository paths as the source code folder. The user just needs to know the internal structure to insert the information about main file etc.
The text was updated successfully, but these errors were encountered:
In GitLab by @ererkka on Mar 30, 2020, 11:21
Status and need
Some GAMS programs have a delicate directory structure, and the main file might not be in the root folder of the project. In case of Balmorel, the project is structured as follows (not all files are show):
Setting this up using the Toolbox interface is possible, but problems start when trying to execute in a work folder. Toolbox takes the folder Balmorel/base/model as the
main_dir
and copies everything from there into a temporary work directory root (i.e. something like /balmorel__xxxxxxxxxxxxxxxxxx__toolbox). But some files and the data should be outside of this folder and on the same or above level in hierarchy, so they end up in wrong places and the GAMS program does not find them.My work-around
My temporary solution is to edit the tool specification file by hand to list the source files like this:
The specification file is stored in the Toolbox project folder alongside with the directory Balmorel which has the source code. Now files are copied into their right places into a temp working dir.
GAMS needs to have the current dir set to where the main program file is located. Toolbox does that by setting the
CurDir
GAMS command line argument. I’ve made the following change to make this work:This will now pass the temp workdir (
basedir
) joined with the main dir (self.main_dir
) to theCurDir
argument. Something like this:and GAMS works nicely.
My proposal
Change the main file selection in the Tool spec. editor into source code folder selector. In the above case that would be folder Balmorel. In addition we need a main file selection box, to set the main program file explicitly, and it will be stored as relative to the source code folder. Other source files will be relative to that folder too.
Benefit: This would probably allow extending (easily?) to support Git repository paths as the source code folder. The user just needs to know the internal structure to insert the information about main file etc.
The text was updated successfully, but these errors were encountered: