src/Pure/Admin/afp.scala
author wenzelm
Sat, 08 Jul 2023 13:13:10 +0200
changeset 78266 d8c99a497502
parent 76883 186e07be32c3
child 78417 01f61cf796e0
permissions -rw-r--r--
clarified signature;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
66820
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/Admin/afp.scala
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
     3
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
     4
Administrative support for the Archive of Formal Proofs.
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
     5
*/
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
     6
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
     7
package isabelle
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
     8
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
     9
69980
f2e3adfd916f tuned signature;
wenzelm
parents: 69979
diff changeset
    10
import java.time.LocalDate
69974
916726680a66 tuned signature;
wenzelm
parents: 69973
diff changeset
    11
import scala.collection.immutable.SortedMap
916726680a66 tuned signature;
wenzelm
parents: 69973
diff changeset
    12
916726680a66 tuned signature;
wenzelm
parents: 69973
diff changeset
    13
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73608
diff changeset
    14
object AFP {
69693
06153e2e0cdb more official AFP.groups;
wenzelm
parents: 67817
diff changeset
    15
  val groups: Map[String, String] =
06153e2e0cdb more official AFP.groups;
wenzelm
parents: 67817
diff changeset
    16
    Map("large" -> "full 64-bit memory model or word arithmetic required",
06153e2e0cdb more official AFP.groups;
wenzelm
parents: 67817
diff changeset
    17
      "slow" -> "CPU time much higher than 60min (on mid-range hardware)",
06153e2e0cdb more official AFP.groups;
wenzelm
parents: 67817
diff changeset
    18
      "very_slow" -> "elapsed time of many hours (on high-end hardware)")
06153e2e0cdb more official AFP.groups;
wenzelm
parents: 67817
diff changeset
    19
70855
8a43ce639d85 tuned signature;
wenzelm
parents: 70854
diff changeset
    20
  val groups_bulky: List[String] = List("large", "slow")
8a43ce639d85 tuned signature;
wenzelm
parents: 70854
diff changeset
    21
8a43ce639d85 tuned signature;
wenzelm
parents: 70854
diff changeset
    22
  val chapter: String = "AFP"
69693
06153e2e0cdb more official AFP.groups;
wenzelm
parents: 67817
diff changeset
    23
70854
85c2cbd35632 tuned signature;
wenzelm
parents: 70100
diff changeset
    24
  val force_partition1: List[String] = List("Category3", "HOL-ODE")
85c2cbd35632 tuned signature;
wenzelm
parents: 70100
diff changeset
    25
75497
0a5f7b5da16f clarified options;
wenzelm
parents: 75393
diff changeset
    26
  val BASE: Path = Path.explode("$AFP_BASE")
0a5f7b5da16f clarified options;
wenzelm
parents: 75393
diff changeset
    27
0a5f7b5da16f clarified options;
wenzelm
parents: 75393
diff changeset
    28
  def init(options: Options, base_dir: Path = BASE): AFP =
66824
49a3a0a6ffaf tuned: less oo-non-sense;
wenzelm
parents: 66823
diff changeset
    29
    new AFP(options, base_dir)
66820
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
    30
69973
a3e3be17dca5 read AFP metadata for entries;
wenzelm
parents: 69787
diff changeset
    31
a3e3be17dca5 read AFP metadata for entries;
wenzelm
parents: 69787
diff changeset
    32
  /* entries */
a3e3be17dca5 read AFP metadata for entries;
wenzelm
parents: 69787
diff changeset
    33
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73608
diff changeset
    34
  def parse_date(s: String): Date = {
69977
3c166df11085 clarified signature: explicitly typed interfaces;
wenzelm
parents: 69976
diff changeset
    35
    val t = Date.Formatter.pattern("uuuu-MM-dd").parse(s)
69980
f2e3adfd916f tuned signature;
wenzelm
parents: 69979
diff changeset
    36
    Date(LocalDate.from(t).atStartOfDay(Date.timezone_berlin))
69977
3c166df11085 clarified signature: explicitly typed interfaces;
wenzelm
parents: 69976
diff changeset
    37
  }
3c166df11085 clarified signature: explicitly typed interfaces;
wenzelm
parents: 69976
diff changeset
    38
69995
2d5c313e8582 more operations;
wenzelm
parents: 69982
diff changeset
    39
  def trim_mail(s: String): String = s.replaceAll("<[^>]*>", "").trim
2d5c313e8582 more operations;
wenzelm
parents: 69982
diff changeset
    40
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73608
diff changeset
    41
  sealed case class Entry(name: String, metadata: Properties.T, sessions: List[String]) {
69977
3c166df11085 clarified signature: explicitly typed interfaces;
wenzelm
parents: 69976
diff changeset
    42
    def get(prop: String): Option[String] = Properties.get(metadata, prop)
3c166df11085 clarified signature: explicitly typed interfaces;
wenzelm
parents: 69976
diff changeset
    43
    def get_string(prop: String): String = get(prop).getOrElse("")
3c166df11085 clarified signature: explicitly typed interfaces;
wenzelm
parents: 69976
diff changeset
    44
    def get_strings(prop: String): List[String] =
70100
wenzelm
parents: 69995
diff changeset
    45
      space_explode(',', get_string(prop)).map(_.trim).filter(_.nonEmpty)
69977
3c166df11085 clarified signature: explicitly typed interfaces;
wenzelm
parents: 69976
diff changeset
    46
3c166df11085 clarified signature: explicitly typed interfaces;
wenzelm
parents: 69976
diff changeset
    47
    def title: String = get_string("title")
3c166df11085 clarified signature: explicitly typed interfaces;
wenzelm
parents: 69976
diff changeset
    48
    def authors: List[String] = get_strings("author")
69981
3dced198b9ec more strict AFP properties;
wenzelm
parents: 69980
diff changeset
    49
    def date: Date =
3dced198b9ec more strict AFP properties;
wenzelm
parents: 69980
diff changeset
    50
      parse_date(get("date").getOrElse(error("Missing date for entry " + quote(name))))
69977
3c166df11085 clarified signature: explicitly typed interfaces;
wenzelm
parents: 69976
diff changeset
    51
    def topics: List[String] = get_strings("topic")
69981
3dced198b9ec more strict AFP properties;
wenzelm
parents: 69980
diff changeset
    52
    def `abstract`: String = get_string("abstract").trim
69977
3c166df11085 clarified signature: explicitly typed interfaces;
wenzelm
parents: 69976
diff changeset
    53
    def maintainers: List[String] = get_strings("notify")
3c166df11085 clarified signature: explicitly typed interfaces;
wenzelm
parents: 69976
diff changeset
    54
    def contributors: List[String] = get_strings("contributors")
69981
3dced198b9ec more strict AFP properties;
wenzelm
parents: 69980
diff changeset
    55
    def license: String = get("license").getOrElse("BSD")
69982
f150253cb201 RDF meta data for AFP entries;
wenzelm
parents: 69981
diff changeset
    56
f150253cb201 RDF meta data for AFP entries;
wenzelm
parents: 69981
diff changeset
    57
    def rdf_meta_data: Properties.T =
f150253cb201 RDF meta data for AFP entries;
wenzelm
parents: 69981
diff changeset
    58
      RDF.meta_data(
f150253cb201 RDF meta data for AFP entries;
wenzelm
parents: 69981
diff changeset
    59
        proper_string(title).map(Markup.META_TITLE -> _).toList :::
f150253cb201 RDF meta data for AFP entries;
wenzelm
parents: 69981
diff changeset
    60
        authors.map(Markup.META_CREATOR -> _) :::
f150253cb201 RDF meta data for AFP entries;
wenzelm
parents: 69981
diff changeset
    61
        contributors.map(Markup.META_CONTRIBUTOR -> _) :::
f150253cb201 RDF meta data for AFP entries;
wenzelm
parents: 69981
diff changeset
    62
        List(Markup.META_DATE -> RDF.date_format(date)) :::
f150253cb201 RDF meta data for AFP entries;
wenzelm
parents: 69981
diff changeset
    63
        List(Markup.META_LICENSE -> license) :::
f150253cb201 RDF meta data for AFP entries;
wenzelm
parents: 69981
diff changeset
    64
        proper_string(`abstract`).map(Markup.META_DESCRIPTION -> _).toList)
69976
98a440cfbb2b provide maintainers as seen in AFP/admin;
wenzelm
parents: 69975
diff changeset
    65
  }
66820
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
    66
}
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
    67
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73608
diff changeset
    68
class AFP private(options: Options, val base_dir: Path) {
66821
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
    69
  override def toString: String = base_dir.expand.toString
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
    70
66820
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
    71
  val main_dir: Path = base_dir + Path.explode("thys")
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
    72
66821
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
    73
69975
wenzelm
parents: 69974
diff changeset
    74
  /* metadata */
wenzelm
parents: 69974
diff changeset
    75
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73608
diff changeset
    76
  private val entry_metadata: Map[String, Properties.T] = {
69975
wenzelm
parents: 69974
diff changeset
    77
    val metadata_file = base_dir + Path.explode("metadata/metadata")
wenzelm
parents: 69974
diff changeset
    78
wenzelm
parents: 69974
diff changeset
    79
    var result = Map.empty[String, Properties.T]
wenzelm
parents: 69974
diff changeset
    80
    var section = ""
wenzelm
parents: 69974
diff changeset
    81
    var props = List.empty[Properties.Entry]
wenzelm
parents: 69974
diff changeset
    82
wenzelm
parents: 69974
diff changeset
    83
    val Section = """^\[(\S+)\]\s*$""".r
wenzelm
parents: 69974
diff changeset
    84
    val Property = """^(\S+)\s*=(.*)$""".r
wenzelm
parents: 69974
diff changeset
    85
    val Extra_Line = """^\s+(.*)$""".r
wenzelm
parents: 69974
diff changeset
    86
    val Blank_Line = """^\s*$""".r
wenzelm
parents: 69974
diff changeset
    87
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73608
diff changeset
    88
    def flush(): Unit = {
69978
4ecdd3eaec04 proper treatment of empty extra lines (amending 98a440cfbb2b);
wenzelm
parents: 69977
diff changeset
    89
      if (section != "") result += (section -> props.reverse.filter(p => p._2.nonEmpty))
69975
wenzelm
parents: 69974
diff changeset
    90
      section = ""
wenzelm
parents: 69974
diff changeset
    91
      props = Nil
wenzelm
parents: 69974
diff changeset
    92
    }
wenzelm
parents: 69974
diff changeset
    93
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73608
diff changeset
    94
    for ((line, i) <- split_lines(File.read(metadata_file)).zipWithIndex) {
69975
wenzelm
parents: 69974
diff changeset
    95
      def err(msg: String): Nothing =
76883
wenzelm
parents: 75497
diff changeset
    96
        error(msg + Position.here(Position.Line_File(i + 1, File.standard_path(metadata_file))))
69975
wenzelm
parents: 69974
diff changeset
    97
wenzelm
parents: 69974
diff changeset
    98
      line match {
wenzelm
parents: 69974
diff changeset
    99
        case Section(name) => flush(); section = name
wenzelm
parents: 69974
diff changeset
   100
        case Property(a, b) =>
wenzelm
parents: 69974
diff changeset
   101
          if (section == "") err("Property without a section")
69978
4ecdd3eaec04 proper treatment of empty extra lines (amending 98a440cfbb2b);
wenzelm
parents: 69977
diff changeset
   102
          props = (a -> b.trim) :: props
69975
wenzelm
parents: 69974
diff changeset
   103
        case Extra_Line(line) =>
wenzelm
parents: 69974
diff changeset
   104
          props match {
wenzelm
parents: 69974
diff changeset
   105
            case Nil => err("Extra line without a property")
wenzelm
parents: 69974
diff changeset
   106
            case (a, b) :: rest => props = (a, b + "\n" + line.trim) :: rest
wenzelm
parents: 69974
diff changeset
   107
          }
wenzelm
parents: 69974
diff changeset
   108
        case Blank_Line() =>
wenzelm
parents: 69974
diff changeset
   109
        case _ => err("Bad input")
wenzelm
parents: 69974
diff changeset
   110
      }
wenzelm
parents: 69974
diff changeset
   111
    }
wenzelm
parents: 69974
diff changeset
   112
wenzelm
parents: 69974
diff changeset
   113
    flush()
wenzelm
parents: 69974
diff changeset
   114
    result
wenzelm
parents: 69974
diff changeset
   115
  }
wenzelm
parents: 69974
diff changeset
   116
wenzelm
parents: 69974
diff changeset
   117
69979
4744e75393d9 clarified signature;
wenzelm
parents: 69978
diff changeset
   118
  /* entries */
66821
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   119
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73608
diff changeset
   120
  val entries_map: SortedMap[String, AFP.Entry] = {
69973
a3e3be17dca5 read AFP metadata for entries;
wenzelm
parents: 69787
diff changeset
   121
    val entries =
69974
916726680a66 tuned signature;
wenzelm
parents: 69973
diff changeset
   122
      for (name <- Sessions.parse_roots(main_dir + Sessions.ROOTS)) yield {
69973
a3e3be17dca5 read AFP metadata for entries;
wenzelm
parents: 69787
diff changeset
   123
        val metadata =
a3e3be17dca5 read AFP metadata for entries;
wenzelm
parents: 69787
diff changeset
   124
          entry_metadata.getOrElse(name, error("Entry without metadata: " + quote(name)))
a3e3be17dca5 read AFP metadata for entries;
wenzelm
parents: 69787
diff changeset
   125
        val sessions =
a3e3be17dca5 read AFP metadata for entries;
wenzelm
parents: 69787
diff changeset
   126
          Sessions.parse_root_entries(main_dir + Path.explode(name) + Sessions.ROOT).map(_.name)
a3e3be17dca5 read AFP metadata for entries;
wenzelm
parents: 69787
diff changeset
   127
        AFP.Entry(name, metadata, sessions)
69974
916726680a66 tuned signature;
wenzelm
parents: 69973
diff changeset
   128
      }
69973
a3e3be17dca5 read AFP metadata for entries;
wenzelm
parents: 69787
diff changeset
   129
69974
916726680a66 tuned signature;
wenzelm
parents: 69973
diff changeset
   130
    val entries_map =
73359
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   131
      entries.foldLeft(SortedMap.empty[String, AFP.Entry]) { case (m, e) => m + (e.name -> e) }
69974
916726680a66 tuned signature;
wenzelm
parents: 69973
diff changeset
   132
69973
a3e3be17dca5 read AFP metadata for entries;
wenzelm
parents: 69787
diff changeset
   133
    val extra_metadata =
69974
916726680a66 tuned signature;
wenzelm
parents: 69973
diff changeset
   134
      (for ((name, _) <- entry_metadata.iterator if !entries_map.isDefinedAt(name)) yield name).
916726680a66 tuned signature;
wenzelm
parents: 69973
diff changeset
   135
        toList.sorted
916726680a66 tuned signature;
wenzelm
parents: 69973
diff changeset
   136
    if (extra_metadata.nonEmpty)
916726680a66 tuned signature;
wenzelm
parents: 69973
diff changeset
   137
      error("Meta data without entry: " + commas_quote(extra_metadata))
69973
a3e3be17dca5 read AFP metadata for entries;
wenzelm
parents: 69787
diff changeset
   138
69974
916726680a66 tuned signature;
wenzelm
parents: 69973
diff changeset
   139
    entries_map
69973
a3e3be17dca5 read AFP metadata for entries;
wenzelm
parents: 69787
diff changeset
   140
  }
66820
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
   141
69974
916726680a66 tuned signature;
wenzelm
parents: 69973
diff changeset
   142
  val entries: List[AFP.Entry] = entries_map.toList.map(_._2)
69979
4744e75393d9 clarified signature;
wenzelm
parents: 69978
diff changeset
   143
4744e75393d9 clarified signature;
wenzelm
parents: 69978
diff changeset
   144
4744e75393d9 clarified signature;
wenzelm
parents: 69978
diff changeset
   145
  /* sessions */
4744e75393d9 clarified signature;
wenzelm
parents: 69978
diff changeset
   146
4744e75393d9 clarified signature;
wenzelm
parents: 69978
diff changeset
   147
  val sessions_map: SortedMap[String, AFP.Entry] =
73359
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   148
    entries.foldLeft(SortedMap.empty[String, AFP.Entry]) {
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   149
      case (m1, e) => e.sessions.foldLeft(m1) { case (m2, s) => m2 + (s -> e) }
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   150
    }
69979
4744e75393d9 clarified signature;
wenzelm
parents: 69978
diff changeset
   151
66821
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   152
  val sessions: List[String] = entries.flatMap(_.sessions)
66824
49a3a0a6ffaf tuned: less oo-non-sense;
wenzelm
parents: 66823
diff changeset
   153
67052
caf87d4b9b61 tuned signature;
wenzelm
parents: 67026
diff changeset
   154
  val sessions_structure: Sessions.Structure =
67026
687c822ee5e3 tuned signature;
wenzelm
parents: 67025
diff changeset
   155
    Sessions.load_structure(options, dirs = List(main_dir)).
67025
961285f581e6 clarifified selection: always wrt. build_graph structure;
wenzelm
parents: 66861
diff changeset
   156
      selection(Sessions.Selection(sessions = sessions.toList))
66821
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   157
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   158
66824
49a3a0a6ffaf tuned: less oo-non-sense;
wenzelm
parents: 66823
diff changeset
   159
  /* dependency graph */
66821
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   160
66824
49a3a0a6ffaf tuned: less oo-non-sense;
wenzelm
parents: 66823
diff changeset
   161
  private def sessions_deps(entry: AFP.Entry): List[String] =
71601
97ccf48c2f0c misc tuning based on hints by IntelliJ IDEA;
wenzelm
parents: 70855
diff changeset
   162
    entry.sessions.flatMap(sessions_structure.imports_graph.imm_preds).distinct.sorted
66824
49a3a0a6ffaf tuned: less oo-non-sense;
wenzelm
parents: 66823
diff changeset
   163
75393
87ebf5a50283 clarified formatting, for the sake of scala3;
wenzelm
parents: 73608
diff changeset
   164
  lazy val entries_graph: Graph[String, Unit] = {
66821
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   165
    val session_entries =
73359
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   166
      entries.foldLeft(Map.empty[String, String]) {
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   167
        case (m1, e) => e.sessions.foldLeft(m1) { case (m2, s) => m2 + (s -> e.name) }
66821
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   168
      }
73359
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   169
    entries.foldLeft(Graph.empty[String, Unit]) {
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   170
      case (g, entry) =>
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   171
        val e1 = entry.name
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   172
        sessions_deps(entry).foldLeft(g.default_node(e1, ())) {
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   173
          case (g1, s) =>
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   174
            session_entries.get(s).filterNot(_ == e1).foldLeft(g1) {
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   175
              case (g2, e2) =>
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   176
                try { g2.default_node(e2, ()).add_edge_acyclic(e2, e1) }
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   177
                catch {
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   178
                  case exn: Graph.Cycles[_] =>
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   179
                    error(cat_lines(exn.cycles.map(cycle =>
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   180
                      "Cyclic dependency of " + cycle.map(c => quote(c.toString)).mkString(" via ") +
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   181
                      " due to session " + quote(s))))
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   182
                }
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
   183
            }
66821
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   184
        }
66824
49a3a0a6ffaf tuned: less oo-non-sense;
wenzelm
parents: 66823
diff changeset
   185
    }
66821
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   186
  }
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   187
66824
49a3a0a6ffaf tuned: less oo-non-sense;
wenzelm
parents: 66823
diff changeset
   188
  def entries_graph_display: Graph_Display.Graph =
49a3a0a6ffaf tuned: less oo-non-sense;
wenzelm
parents: 66823
diff changeset
   189
    Graph_Display.make_graph(entries_graph)
66823
f529719cc47d operations for graph display;
wenzelm
parents: 66821
diff changeset
   190
66824
49a3a0a6ffaf tuned: less oo-non-sense;
wenzelm
parents: 66823
diff changeset
   191
  def entries_json_text: String =
49a3a0a6ffaf tuned: less oo-non-sense;
wenzelm
parents: 66823
diff changeset
   192
    (for (entry <- entries.iterator) yield {
49a3a0a6ffaf tuned: less oo-non-sense;
wenzelm
parents: 66823
diff changeset
   193
      val distrib_deps = sessions_deps(entry).filterNot(sessions.contains(_))
49a3a0a6ffaf tuned: less oo-non-sense;
wenzelm
parents: 66823
diff changeset
   194
      val afp_deps = entries_graph.imm_preds(entry.name).toList
49a3a0a6ffaf tuned: less oo-non-sense;
wenzelm
parents: 66823
diff changeset
   195
      """
66821
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   196
 {""" + JSON.Format(entry.name) + """:
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   197
  {"distrib_deps": """ + JSON.Format(distrib_deps) + """,
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   198
   "afp_deps": """ + JSON.Format(afp_deps) + """
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   199
  }
c0e8c199cb2e dependencies of entries vs. sessions;
wenzelm
parents: 66820
diff changeset
   200
 }"""
66824
49a3a0a6ffaf tuned: less oo-non-sense;
wenzelm
parents: 66823
diff changeset
   201
    }).mkString("[", ", ", "\n]\n")
66861
f6676691ef8a partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents: 66854
diff changeset
   202
f6676691ef8a partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents: 66854
diff changeset
   203
f6676691ef8a partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents: 66854
diff changeset
   204
  /* partition sessions */
f6676691ef8a partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents: 66854
diff changeset
   205
f6676691ef8a partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents: 66854
diff changeset
   206
  def partition(n: Int): List[String] =
f6676691ef8a partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents: 66854
diff changeset
   207
    n match {
f6676691ef8a partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents: 66854
diff changeset
   208
      case 0 => Nil
f6676691ef8a partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents: 66854
diff changeset
   209
      case 1 | 2 =>
f6676691ef8a partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents: 66854
diff changeset
   210
        val graph = sessions_structure.build_graph.restrict(sessions.toSet)
67817
93faefc25fe7 clarified AFP partitioning;
wenzelm
parents: 67815
diff changeset
   211
        val force_part1 =
71601
97ccf48c2f0c misc tuning based on hints by IntelliJ IDEA;
wenzelm
parents: 70855
diff changeset
   212
          graph.all_preds(graph.all_succs(AFP.force_partition1.filter(graph.defined))).toSet
67817
93faefc25fe7 clarified AFP partitioning;
wenzelm
parents: 67815
diff changeset
   213
        val (part1, part2) = graph.keys.partition(a => force_part1(a) || graph.is_isolated(a))
93faefc25fe7 clarified AFP partitioning;
wenzelm
parents: 67815
diff changeset
   214
        if (n == 1) part1 else part2
66861
f6676691ef8a partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents: 66854
diff changeset
   215
      case _ => error("Bad AFP partition: " + n + " (should be 0, 1, 2)")
f6676691ef8a partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents: 66854
diff changeset
   216
    }
66820
fc516da7ee4f some administrative support for AFP;
wenzelm
parents:
diff changeset
   217
}