From 306d9d0af65c2c1deedcf83199b3355cfb3afbdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Grali=C5=84ski?= Date: Fri, 29 Jun 2018 08:05:33 +0200 Subject: [PATCH 1/3] update for GEval 1.1.0.0 --- Handler/ShowChallenge.hs | 6 ++++-- gonito.cabal | 2 +- stack.yaml | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Handler/ShowChallenge.hs b/Handler/ShowChallenge.hs index 9ebb06e..285e98a 100644 --- a/Handler/ShowChallenge.hs +++ b/Handler/ShowChallenge.hs @@ -34,6 +34,8 @@ import Data.Attoparsec.Text import Data.Text (pack, unpack) +import Data.Conduit.SmartSource + getShowChallengeR :: Text -> Handler Html getShowChallengeR name = do (Entity challengeId challenge) <- runDB $ getBy404 $ UniqueName name @@ -325,7 +327,7 @@ checkOrInsertEvaluation repoDir chan out = do case resultOrException of Right (Left _) -> do err chan "Cannot parse options, check the challenge repo" - Right (Right (_, Just [result])) -> do + Right (Right (_, Just [(_, [result])])) -> do msg chan $ concat [ "Evaluated! Score ", (T.pack $ show result) ] time <- liftIO getCurrentTime _ <- runDB $ insert $ Evaluation { @@ -342,7 +344,7 @@ checkOrInsertEvaluation repoDir chan out = do Left exception -> do err chan $ "Evaluation failed: " ++ (T.pack $ show exception) -rawEval :: FilePath -> Metric -> FilePath -> Text -> IO (Either GEvalException (Either (ParserResult GEvalOptions) (GEvalOptions, Maybe [MetricValue]))) +rawEval :: FilePath -> Metric -> FilePath -> Text -> IO (Either GEvalException (Either (ParserResult GEvalOptions) (GEvalOptions, Maybe [(SourceSpec, [MetricValue])]))) rawEval challengeDir metric repoDir name = Import.try (runGEvalGetOptions [ "--alt-metric", (show metric), "--expected-directory", challengeDir, diff --git a/gonito.cabal b/gonito.cabal index cf81981..bd42688 100644 --- a/gonito.cabal +++ b/gonito.cabal @@ -122,7 +122,7 @@ library , filemanip , cryptohash , markdown - , geval >= 1.0.0.0 + , geval >= 1.1.0.0 && < 1.2 , filepath , yesod-table , regex-tdfa diff --git a/stack.yaml b/stack.yaml index 2027359..bc55577 100644 --- a/stack.yaml +++ b/stack.yaml @@ -8,7 +8,7 @@ packages: git: https://github.com/bitemyapp/esqueleto commit: b81e0d951e510ebffca03c5a58658ad884cc6fbd extra-dep: true -extra-deps: [../geval,wai-handler-fastcgi-3.0.0.2,murmur3-1.0.3,random-strings-0.1.1.0] +extra-deps: [../geval,wai-handler-fastcgi-3.0.0.2,murmur3-1.0.3,random-strings-0.1.1.0,naturalcomp-0.0.3] resolver: lts-11.9 image: container: From 52ae6ae9a5ed765ec17e74915d1f646dc60a27c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Grali=C5=84ski?= Date: Wed, 4 Jul 2018 16:22:10 +0200 Subject: [PATCH 2/3] start transition to multiple variants per submission --- Handler/ShowChallenge.hs | 1 + config/models | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Handler/ShowChallenge.hs b/Handler/ShowChallenge.hs index 285e98a..ed43815 100644 --- a/Handler/ShowChallenge.hs +++ b/Handler/ShowChallenge.hs @@ -302,6 +302,7 @@ outForTest repoDir submissionId (Entity testId test) = do checksum <- liftIO $ gatherSHA1ForCollectionOfFiles [outF] return Out { outSubmission=submissionId, + outVariant=Nothing, outTest=testId, outChecksum=SHA1 checksum } diff --git a/config/models b/config/models index cc32007..93eeda4 100644 --- a/config/models +++ b/config/models @@ -59,6 +59,10 @@ Submission isPublic Bool default=False isHidden Bool Maybe UniqueSubmissionRepoCommitChallenge repo commit challenge +Variant + submission SubmissionId + name Text + UniqueVariantSubmissionName submission name Fork source SubmissionId target SubmissionId @@ -77,6 +81,7 @@ Comment text Textarea Out submission SubmissionId + variant VariantId Maybe test TestId checksum SHA1 UniqueOutSubmissionTestChecksum submission test checksum From aa000b1a9445e942120aace4b6f8e6780db159f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Grali=C5=84ski?= Date: Wed, 4 Jul 2018 16:43:50 +0200 Subject: [PATCH 3/3] helper script for transition to multiple variants --- add-variants.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 add-variants.sql diff --git a/add-variants.sql b/add-variants.sql new file mode 100644 index 0000000..82b144e --- /dev/null +++ b/add-variants.sql @@ -0,0 +1,9 @@ + +insert into variant(submission, name) select id, 'out' from submission; + +update out +set variant=subquery.variant_id +from (select O.id as out_id, V.id as variant_id + from out as O, variant as V, submission as S + where V.submission = S.id and O.submission = S.id) AS subquery +where out.id = subquery.out_id;