metric is now obligatory for test in the DB

This commit is contained in:
Filip Gralinski 2015-12-20 21:00:00 +01:00
parent b30532ee9c
commit c6a6ee45f4
4 changed files with 25 additions and 14 deletions

View File

@ -7,6 +7,9 @@ import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3,
import Handler.Shared import Handler.Shared
import Handler.Extract import Handler.Extract
import GEval.Core
import GEval.OptionsParser
import System.Directory (doesFileExist) import System.Directory (doesFileExist)
import System.FilePath.Find as SFF import System.FilePath.Find as SFF
import System.FilePath import System.FilePath
@ -84,7 +87,7 @@ updateTests challengeId chan = do
repo <- runDB $ get404 repoId repo <- runDB $ get404 repoId
let commit = repoCurrentCommit repo let commit = repoCurrentCommit repo
testDirs <- liftIO $ findTestDirs repoDir testDirs <- liftIO $ findTestDirs repoDir
mapM_ (checkTestDir chan challengeId commit) testDirs mapM_ (checkTestDir chan challengeId challenge commit) testDirs
msg chan (T.pack $ show testDirs) msg chan (T.pack $ show testDirs)
return () return ()
@ -93,16 +96,24 @@ expectedFileName = "expected.tsv"
doesExpectedExist :: FilePath -> IO Bool doesExpectedExist :: FilePath -> IO Bool
doesExpectedExist fp = doesFileExist (fp </> expectedFileName) doesExpectedExist fp = doesFileExist (fp </> expectedFileName)
checkTestDir :: Channel -> (Key Challenge) -> SHA1 -> FilePath -> Handler () checkTestDir :: Channel -> (Key Challenge) -> Challenge -> SHA1 -> FilePath -> Handler ()
checkTestDir chan challengeId commit testDir = do checkTestDir chan challengeId challenge commit testDir = do
expectedExists <- liftIO $ doesExpectedExist testDir expectedExists <- liftIO $ doesExpectedExist testDir
if expectedExists if expectedExists
then do then do
msg chan $ concat ["Test dir ", (T.pack testDir), " found."] msg chan $ concat ["Test dir ", (T.pack testDir), " found."]
checksum <- liftIO $ gatherSHA1 testDir checksum <- liftIO $ gatherSHA1 testDir
testId <- runDB $ insert $ Test { 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, testChallenge=challengeId,
testMetric=Nothing, testMetric=gesMetric $ geoSpec opts,
testName=T.pack $ takeFileName testDir, testName=T.pack $ takeFileName testDir,
testChecksum=(SHA1 checksum), testChecksum=(SHA1 checksum),
testCommit=commit, testCommit=commit,

View File

@ -62,7 +62,7 @@ getLeaderboardEntries challengeId = do
Nothing -> [])) Nothing -> []))
compareResult :: Test -> Maybe Double -> Maybe Double -> Ordering 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 _ (Just _) Nothing = GT
compareResult _ Nothing (Just _) = LT compareResult _ Nothing (Just _) = LT
compareResult _ Nothing Nothing = EQ compareResult _ Nothing Nothing = EQ

View File

@ -33,7 +33,7 @@ Challenge
stamp UTCTime default=now() stamp UTCTime default=now()
Test Test
challenge ChallengeId challenge ChallengeId
metric Metric Maybe metric Metric
name Text name Text
checksum SHA1 checksum SHA1
commit SHA1 commit SHA1

View File

@ -1,6 +1,6 @@
<h1>Welcome to Gonito.net! <h1>Welcome to Gonito.net!
<p>Gonito (pronounced <i>ɡɔ̃ˈɲitɔ</i>) is a Kaggle-like platform for machine learning competitions. <p>Gonito (pronounced <i>ɡɔ̃ˈɲitɔ</i>) is a Kaggle-like platform for machine learning competitions (disclaimer: Gonito is neither affiliated with nor endorsed by <a href="https://www.kaggle.com">Kaggle</a>)
<p>What's so special about Gonito: <p>What's so special about Gonito: