diff --git a/Handler/CreateChallenge.hs b/Handler/CreateChallenge.hs index 07f2db0..414907a 100644 --- a/Handler/CreateChallenge.hs +++ b/Handler/CreateChallenge.hs @@ -7,6 +7,9 @@ import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3, import Handler.Shared import Handler.Extract +import GEval.Core +import GEval.OptionsParser + import System.Directory (doesFileExist) import System.FilePath.Find as SFF import System.FilePath @@ -84,7 +87,7 @@ updateTests challengeId chan = do repo <- runDB $ get404 repoId let commit = repoCurrentCommit repo testDirs <- liftIO $ findTestDirs repoDir - mapM_ (checkTestDir chan challengeId commit) testDirs + mapM_ (checkTestDir chan challengeId challenge commit) testDirs msg chan (T.pack $ show testDirs) return () @@ -93,21 +96,29 @@ expectedFileName = "expected.tsv" doesExpectedExist :: FilePath -> IO Bool doesExpectedExist fp = doesFileExist (fp expectedFileName) -checkTestDir :: Channel -> (Key Challenge) -> SHA1 -> FilePath -> Handler () -checkTestDir chan challengeId commit testDir = do +checkTestDir :: Channel -> (Key Challenge) -> Challenge -> SHA1 -> FilePath -> Handler () +checkTestDir chan challengeId challenge commit testDir = do expectedExists <- liftIO $ doesExpectedExist testDir if expectedExists then do msg chan $ concat ["Test dir ", (T.pack testDir), " found."] checksum <- liftIO $ gatherSHA1 testDir - testId <- runDB $ insert $ Test { - testChallenge=challengeId, - testMetric=Nothing, - testName=T.pack $ takeFileName testDir, - testChecksum=(SHA1 checksum), - testCommit=commit, - testActive=True } - return () + optionsParsingResult <- liftIO $ getOptions [ + "--expected-directory", (getRepoDir $ challengePrivateRepo challenge), + "--test-name", takeFileName testDir] + case optionsParsingResult of + Left evalException -> do + err chan "Cannot read metric" + return () + Right opts -> do + _ <- runDB $ insert $ Test { + testChallenge=challengeId, + testMetric=gesMetric $ geoSpec opts, + testName=T.pack $ takeFileName testDir, + testChecksum=(SHA1 checksum), + testCommit=commit, + testActive=True } + return () else msg chan $ concat ["Test dir ", (T.pack testDir), " does not have expected results."] return () diff --git a/Handler/Tables.hs b/Handler/Tables.hs index 9c977f7..dd8b392 100644 --- a/Handler/Tables.hs +++ b/Handler/Tables.hs @@ -62,7 +62,7 @@ getLeaderboardEntries challengeId = do Nothing -> [])) compareResult :: Test -> Maybe Double -> Maybe Double -> Ordering -compareResult test (Just x) (Just y) = (DM.fromMaybe compare (compareFun <$> getMetricOrdering <$> testMetric test)) x y +compareResult test (Just x) (Just y) = (compareFun $ getMetricOrdering $ testMetric test) x y compareResult _ (Just _) Nothing = GT compareResult _ Nothing (Just _) = LT compareResult _ Nothing Nothing = EQ diff --git a/config/models b/config/models index be6d909..4784b77 100644 --- a/config/models +++ b/config/models @@ -33,7 +33,7 @@ Challenge stamp UTCTime default=now() Test challenge ChallengeId - metric Metric Maybe + metric Metric name Text checksum SHA1 commit SHA1 diff --git a/templates/homepage.hamlet b/templates/homepage.hamlet index f4d7df7..b3052c3 100644 --- a/templates/homepage.hamlet +++ b/templates/homepage.hamlet @@ -1,6 +1,6 @@

Welcome to Gonito.net! -

Gonito (pronounced ɡɔ̃ˈɲitɔ) is a Kaggle-like platform for machine learning competitions. +

Gonito (pronounced ɡɔ̃ˈɲitɔ) is a Kaggle-like platform for machine learning competitions (disclaimer: Gonito is neither affiliated with nor endorsed by Kaggle)

What's so special about Gonito: