Skip to content

Commit

Permalink
Misc Bugfixes (closes #296)
Browse files Browse the repository at this point in the history
- Clean up working directory for scala cells.
- Replace deprecated File.renameTo() with Files.move() in UnloadDataset
- Invert axes in CDFs per #296
  • Loading branch information
okennedy committed Dec 23, 2023
1 parent a86bef6 commit de8ad2c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
23 changes: 19 additions & 4 deletions vizier/backend/src/info/vizierdb/Vizier.scala
Expand Up @@ -140,7 +140,7 @@ object Vizier
}
}

def launchUIIfPossible()
def launchUIIfPossible(): Unit =
{
val command: Seq[String] =
System.getProperty("os.name").toLowerCase match {
Expand All @@ -159,6 +159,22 @@ object Vizier
}
}

def setWorkingDirectory(): Unit =
{
if(config.workingDirectory.isDefined){
val path = new File(config.workingDirectory()).getAbsolutePath()
System.setProperty("user.dir", path)
}
}

def setWorkingDirectory(): Unit =
{
if(config.workingDirectory.isDefined){
val path = new File(config.workingDirectory()).getAbsolutePath()
System.setProperty("user.dir", path)
}
}

def main(args: Array[String])
{
config = new Config(args)
Expand All @@ -183,9 +199,7 @@ object Vizier
Schema.initialize()
// initORMLogging("warn")
bringDatabaseToSaneState()
if(config.workingDirectory.isDefined){
System.setProperty("user.dir", new File(config.workingDirectory()).getAbsolutePath())
}
setWorkingDirectory()

// Set up Mimir
println("Starting Spark...")
Expand Down Expand Up @@ -322,6 +336,7 @@ object Vizier
}
BrowseFilesystem.mountPublishedArtifacts()

println(s"... working directory < ${System.getProperty("user.dir")} >")
println(s"... server running at < ${urls.ui} >")

// Don't auto-launch the UI if we're asked not to
Expand Down
Expand Up @@ -28,6 +28,8 @@ import info.vizierdb.catalog.CatalogDB
import info.vizierdb.Vizier
import java.net.URL
import info.vizierdb.VizierException
import java.nio.file.Files
import java.nio.file.StandardCopyOption

object UnloadDataset extends Command
with LazyLogging
Expand Down Expand Up @@ -245,11 +247,15 @@ object UnloadDataset extends Command
.getOrElse {
outputArtifactIfNeeded.get.absoluteFile
}
logger.info(s"Moving ${dataFiles.head} to $finalOutputFile")
dataFiles.head.renameTo(finalOutputFile)
for(f <- allFiles){
if(f.exists && f != dataFiles.head){ f.delete }
}
logger.info(s"Moving ${dataFiles.head} to $finalOutputFile")
Files.move(
dataFiles.head.toPath,
finalOutputFile.toPath,
StandardCopyOption.REPLACE_EXISTING
)
tempDir.get.delete
new URL("file://" + finalOutputFile.getAbsolutePath())
} else { file }
Expand Down
6 changes: 3 additions & 3 deletions vizier/backend/src/info/vizierdb/commands/plot/CDFPlot.scala
Expand Up @@ -53,7 +53,7 @@ object CDFPlot extends Command
override def parameters: Seq[Parameter] = Seq(
ListParameter(id = PARAM_SERIES, name = "Lines", components = Seq(
DatasetParameter(id = PARAM_DATASET, name = "Dataset"),
ColIdParameter(id = PARAM_X, name = "X-axis"),
ColIdParameter(id = PARAM_X, name = "CDF"),
StringParameter(id = PARAM_LABEL, name = "Label", required = false),
StringParameter(id = PARAM_FILTER, name = "Filter", required = false, helpText = Some("e.g., state = 'NY'")),
StringParameter(id = PARAM_COLOR, name = "Color", required = false, helpText = Some("e.g., #214478")),
Expand Down Expand Up @@ -83,8 +83,8 @@ object CDFPlot extends Command
PlotUtils.makeSeries(
context = context,
datasetName = series.get[String](PARAM_DATASET),
xIndex = series.get[Int](PARAM_X),
yIndex = series.get[Int](PARAM_X), // this is just a placeholder; CDF below replaces it
xIndex = series.get[Int](PARAM_X), // this is just a placeholder; CDF below replaces it
yIndex = series.get[Int](PARAM_X),
name = series.getOpt[String](PARAM_LABEL),
)
.filtered(series.getOpt[String](PARAM_FILTER).getOrElse(""))
Expand Down
Expand Up @@ -190,7 +190,7 @@ object PlotUtils

copy(
dataframe = newDataframe,
y = cdf_attr
x = cdf_attr
)
}

Expand Down

0 comments on commit de8ad2c

Please sign in to comment.