diff --git a/Handler/CreateChallenge.hs b/Handler/CreateChallenge.hs index 69fd9b9..b2001ae 100644 --- a/Handler/CreateChallenge.hs +++ b/Handler/CreateChallenge.hs @@ -12,6 +12,7 @@ import GEval.Core import GEval.OptionsParser import GEval.EvaluationScheme import GEval.Validation +import GEval.Common (FormattingOptions(..)) import Gonito.ExtractMetadata (getLastCommitMessage) @@ -392,7 +393,7 @@ insertOrUpdateTest testDir challengeId checksum commit opts (priority, metric) = mAlreadyExistingTest <- getBy $ UniqueChallengeNameMetricChecksum challengeId name metric checksum case mAlreadyExistingTest of Just (Entity testId _) -> update testId [TestCommit=.commit, - TestPrecision=.(gesPrecision $ geoSpec opts), + TestPrecision=. (decimalPlaces $ gesFormatting $ geoSpec opts), TestPriority=.Just priority] Nothing -> do _ <- insert $ Test { @@ -402,7 +403,7 @@ insertOrUpdateTest testDir challengeId checksum commit opts (priority, metric) = testChecksum=checksum, testCommit=commit, testActive=True, - testPrecision=gesPrecision $ geoSpec opts, + testPrecision=decimalPlaces $ gesFormatting $ geoSpec opts, testPriority=Just priority} return () diff --git a/Handler/Evaluate.hs b/Handler/Evaluate.hs index df1516e..3082faa 100644 --- a/Handler/Evaluate.hs +++ b/Handler/Evaluate.hs @@ -16,6 +16,7 @@ import qualified Data.Text as T import qualified Data.Map.Strict as M import GEval.Core +import GEval.Common import GEval.EvaluationScheme import GEval.OptionsParser import GEval.ParseParams (parseParamsFromFilePath, OutputFileParsed(..)) @@ -224,7 +225,10 @@ checkOrInsertEvaluation repoDir chan version out = do Right (Left _) -> do err chan "Cannot parse options, check the challenge repo" Right (Right (_, Just [(_, [result])])) -> do - msg chan $ concat [ "Evaluated! Score ", (T.pack $ formatTheResult Nothing result) ] + let defaultFormattingOpts = FormattingOptions { + decimalPlaces = Nothing, + asPercentage = False } + msg chan $ concat [ "Evaluated! Score ", (T.pack $ formatTheResult defaultFormattingOpts result) ] time <- liftIO getCurrentTime _ <- runDB $ insert $ let (pointResult, errorBound) = extractResult result in Evaluation { diff --git a/Handler/Query.hs b/Handler/Query.hs index 4d0ddfc..0dd6ad1 100644 --- a/Handler/Query.hs +++ b/Handler/Query.hs @@ -27,6 +27,7 @@ import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3) import Data.Conduit.SmartSource (lookForCompressedFiles) import GEval.Core (GEvalSpecification(..), ResultOrdering(..)) import GEval.LineByLine (runLineByLineGeneralized, LineRecord(..)) +import GEval.Common (FormattingOptions(..)) import qualified Data.Conduit.List as CL import System.FilePath (takeFileName) @@ -279,7 +280,9 @@ viewOutput entry tests (outputHash, testSet) = do gesExpectedFile = "expected.tsv", gesInputFile = "in.tsv", gesMetrics = [mainMetric], - gesPrecision = Nothing, + gesFormatting = FormattingOptions { + decimalPlaces = Nothing, + asPercentage = False }, gesTokenizer = Nothing, gesGonitoHost = Nothing, gesToken = Nothing, @@ -287,7 +290,8 @@ viewOutput entry tests (outputHash, testSet) = do gesReferences = Nothing, gesBootstrapResampling = Nothing, gesInHeader = Nothing, - gesOutHeader = Nothing } + gesOutHeader = Nothing, + gesShowPreprocessed = True } result <- liftIO $ runLineByLineGeneralized FirstTheWorst spec (\_ -> CL.take 20) diff --git a/Handler/Shared.hs b/Handler/Shared.hs index 21dde16..6d5399a 100644 --- a/Handler/Shared.hs +++ b/Handler/Shared.hs @@ -40,6 +40,7 @@ import System.IO.Unsafe (unsafePerformIO) import Text.Regex.TDFA import GEval.Core +import GEval.Common import GEval.EvaluationScheme import GEval.Formatting (formatTheResultWithErrorBounds) @@ -450,8 +451,13 @@ formatTruncatedScore :: Maybe Int -> Maybe Evaluation -> Text formatTruncatedScore Nothing e = formatFullScore e formatTruncatedScore _ Nothing = formatFullScore Nothing formatTruncatedScore (Just precision) (Just evaluation) = case evaluationScore evaluation of - Just score -> T.pack $ formatTheResultWithErrorBounds (Just precision) score (evaluationErrorBound evaluation) + Just score -> T.pack $ formatTheResultWithErrorBounds formattingOpts score (evaluationErrorBound evaluation) Nothing -> formatFullScore Nothing + where formattingOpts = FormattingOptions { + decimalPlaces = Just precision, + asPercentage = False + } + formatScore :: Maybe Int -> Double -> Text formatScore Nothing = T.pack . show diff --git a/gonito.cabal b/gonito.cabal index 3f76d68..d21b731 100644 --- a/gonito.cabal +++ b/gonito.cabal @@ -1,5 +1,5 @@ name: gonito -version: 0.1.0 +version: 0.1.1 cabal-version: >= 1.8 build-type: Simple homepage: http://gonito.net @@ -129,7 +129,7 @@ library , filemanip , cryptohash , markdown - , geval >= 1.32 && < 1.37 + , geval >= 1.37 && < 1.38 , filepath , yesod-table , regex-tdfa