about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-08-21 15:33:05 -0500
committerFrederick Muriuki Muriithi2025-10-08 08:52:00 -0500
commitec2cc2d4131d7f0b3104cf45ab2a59ad26d9e7dc (patch)
treedb149be6bd88009ca72842ebebec03c219fac90c
parent566eb7a555cdf17c5904b50a1bdd9511831008f1 (diff)
downloadgn-machines-ec2cc2d4131d7f0b3104cf45ab2a59ad26d9e7dc.tar.gz
Define and schedule "samples counts" script to run.
-rw-r--r--genenetwork/services/genenetwork.scm31
1 files changed, 30 insertions, 1 deletions
diff --git a/genenetwork/services/genenetwork.scm b/genenetwork/services/genenetwork.scm
index 8df566f..0281c5a 100644
--- a/genenetwork/services/genenetwork.scm
+++ b/genenetwork/services/genenetwork.scm
@@ -259,6 +259,32 @@
                             (chmod file #o644))
                           (find-files #$xapian-directory)))))))))
 
+(define (samples-count-script-gexp config)
+  (match-record config <genenetwork-configuration>
+                (genenetwork2 sql-uri)
+    (with-imported-modules '((guix build utils))
+      #~(begin
+          (use-modules (guix build utils))
+
+          (setenv "PYTHONPATH"
+                  (string-append
+                   #$(file-append genenetwork2
+                                  "/lib/python"
+                                  (python-version (package-version python))
+                                  "/site-packages")
+                   ":"
+                   #$(profile
+                       (content (package->development-manifest genenetwork2))
+                       (allow-collisions? #t))
+                   "/lib/python"
+                   #$(python-version (package-version python))
+                   "/site-packages"))
+
+          (invoke #$(file-append python "/bin/python3")
+                  "-m"
+                  "gn2.scripts.sample_count"
+                  #$sql-uri)))))
+
 (define (genenetwork-activation config)
   (match-record config <genenetwork-configuration>
     (gn2-secrets gn3-secrets gn-auth-secrets auth-db llm-db-path genotype-files gn-tmpdir gn-doc-git-checkout gn2-sessions-dir)
@@ -621,7 +647,10 @@ a @code{<genenetwork-configuration>} record."
   (list #~(job '(next-hour)
                #$(program-file "build-xapian-index-cron-gexp"
                                (build-xapian-index-cron-gexp config))
-               #:user "root")))
+               #:user "root")
+        #~(job '(next-minute-from (next-hour) '(17)) ;17th minute of every hour
+               #$(program-file "samples-count-script-gexp"
+                               (samples-count-script-gexp config)))))
 
 (define (gn-guile-gexp gn-guile-port gn-guile-pkg)
   (with-imported-modules '((guix build utils))