Skip to content

Commit

Permalink
[R API] fix config and local HSQLDB path issues, update tutorials (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann authored Feb 2, 2018
1 parent afab623 commit 46ddf84
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
7 changes: 5 additions & 2 deletions ixmp/ixmp.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ ixmp_r_path = Sys.getenv("IXMP_R_PATH")
java.pars <- paste0("-Djava.ext.dirs=", file.path(ixmp_r_path, "lib"))
options(java.parameters = java.pars)

# path to access the local db
local_path <- file.path(paste0(gsub("Documents.*","",path.expand("~")),".local/ixmp"))

## Launch the java virtual machine, add ixmp_r_path (in addition to jar file)
.jinit(file.path(ixmp_r_path, "ixmp.jar"))
.jaddClassPath(ixmp_r_path)
Expand All @@ -40,15 +43,15 @@ ixmp.Platform <- setRefClass("ixmp.Platform",
if (is.null(dbtype)) {
if (is.null(dbprops)) dbprops = 'default.properties'
if (!file.exists(dbprops)) {
dbprops = paste(message_ix_path, "/config/",dbprops, sep = '')
dbprops = paste(message_ix_path, "/ixmp/config/",dbprops, sep = '')
if (!file.exists(dbprops)) {
stop('no properties file ', dbprops , '!')
}
}
print(paste0("launching ixmp.Platform using config file at ", dbprops))
.jobj <<- new(java.Platform, "R", dbprops)
} else {
if (is.null(dbprops)) stop('Please specify a local database file!')
if (is.null(dbprops)) dbprops = paste(local_path, "/localdb/default", sep = '')
print(paste0("launching ixmp.Platform with local ",dbtype," database at "
, dbprops))
.jobj <<- new(java.Platform, "R", dbprops, dbtype)
Expand Down
4 changes: 1 addition & 3 deletions tutorial/transport/R_transport.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@
"outputs": [],
"source": [
"# launch the ix modeling platform using a local HSQL database instance\n",
"mp <- ixmp.Platform(\"C:\\\\Users\\\\<user>\\\\.local\\\\ixmp\\\\localdb\\\\default2\", \"HSQLDB\")\n",
"\n",
"# TODO: the R package does not yet have an internal default path to a local directory for HSQL database instances"
"mp <- ixmp.Platform(dbtype=\"HSQLDB\")"
]
},
{
Expand Down
4 changes: 1 addition & 3 deletions tutorial/transport/R_transport_scenario.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@
"outputs": [],
"source": [
"# launch the ix modeling platform using the local default database \n",
"mp <- ixmp.Platform(\"C:\\\\Users\\\\<user>\\\\.local\\\\ixmp\\\\localdb\\\\default\", \"HSQLDB\")\n",
"\n",
"# TODO: the R package does not yet have an internal default path to a local directory for HSQL database instances"
"mp <- ixmp.Platform(dbtype=\"HSQLDB\")"
]
},
{
Expand Down

0 comments on commit 46ddf84

Please sign in to comment.