Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# These "empty" enums (they must have at least one element) will be replaced at runtime with

Check failure on line 1 in modules/schema/src/main/resources/lucuma/odb/graphql/OdbSchema.graphql

View workflow job for this annotation

GitHub Actions / Validate ODB Public API

Type 'ProgramUserSupportRoleType' was removed

Type 'ProgramUserSupportRoleType' was removed
# definitions based on database tables.

enum ConditionsMeasurementSource {
Expand Down Expand Up @@ -1456,7 +1456,7 @@
"""
GCAL filter
"""
enum GcalFilter {

Check failure on line 1459 in modules/schema/src/main/resources/lucuma/odb/graphql/OdbSchema.graphql

View workflow job for this annotation

GitHub Actions / Validate ODB Public API

Enum value 'HROS' was removed from enum 'GcalFilter'

Removing an enum value will cause existing queries that use this enum value to error.

Check failure on line 1459 in modules/schema/src/main/resources/lucuma/odb/graphql/OdbSchema.graphql

View workflow job for this annotation

GitHub Actions / Validate ODB Public API

Enum value 'ND16' was removed from enum 'GcalFilter'

Removing an enum value will cause existing queries that use this enum value to error.

Check failure on line 1459 in modules/schema/src/main/resources/lucuma/odb/graphql/OdbSchema.graphql

View workflow job for this annotation

GitHub Actions / Validate ODB Public API

Enum value 'ND50' was removed from enum 'GcalFilter'

Removing an enum value will cause existing queries that use this enum value to error.
"""
GcalFilter None
"""
Expand All @@ -1467,11 +1467,6 @@
"""
GMOS

"""
GcalFilter Hros
"""
HROS

"""
GcalFilter Nir
"""
Expand All @@ -1482,11 +1477,6 @@
"""
ND10

"""
GcalFilter Nd16
"""
ND16

"""
GcalFilter Nd20
"""
Expand All @@ -1507,10 +1497,6 @@
"""
ND45

"""
GcalFilter Nd50
"""
ND50
}

"""
Expand Down Expand Up @@ -3915,15 +3901,6 @@
SUPPORT_SECONDARY
}

"""
The type of support role.
"""
enum ProgramUserSupportRoleType {
"Staff support"
STAFF
"Partner support"
PARTNER
}

"""
An assignment of a user to a program.
Expand Down Expand Up @@ -6631,7 +6608,7 @@
"""
ObservingMode
"""
enum ObservingModeType {

Check failure on line 6611 in modules/schema/src/main/resources/lucuma/odb/graphql/OdbSchema.graphql

View workflow job for this annotation

GitHub Actions / Validate ODB Public API

Enum value 'FLAMINGOS_2LONG_SLIT' was removed from enum 'ObservingModeType'

Removing an enum value will cause existing queries that use this enum value to error.
"""
ObservingModeType GmosNorthLongSlit
"""
Expand All @@ -6645,7 +6622,7 @@
"""
ObservingModeType Flamingos2LongSlit
"""
FLAMINGOS_2LONG_SLIT
FLAMINGOS_2_LONG_SLIT

Check warning on line 6625 in modules/schema/src/main/resources/lucuma/odb/graphql/OdbSchema.graphql

View workflow job for this annotation

GitHub Actions / Validate ODB Public API

Enum value 'FLAMINGOS_2_LONG_SLIT' was added to enum 'ObservingModeType'

Adding an enum value may break existing clients that were not programming defensively against an added case when querying an enum.

"""
ObservingModeType GmosNorthImaging
Expand Down Expand Up @@ -11497,6 +11474,8 @@
LIBRARY
SCIENCE
SYSTEM
MONITORING

Check warning on line 11477 in modules/schema/src/main/resources/lucuma/odb/graphql/OdbSchema.graphql

View workflow job for this annotation

GitHub Actions / Validate ODB Public API

Enum value 'MONITORING' was added to enum 'ProgramType'

Adding an enum value may break existing clients that were not programming defensively against an added case when querying an enum.
COMMISSIONING

Check warning on line 11478 in modules/schema/src/main/resources/lucuma/odb/graphql/OdbSchema.graphql

View workflow job for this annotation

GitHub Actions / Validate ODB Public API

Enum value 'COMMISSIONING' was added to enum 'ProgramType'

Adding an enum value may break existing clients that were not programming defensively against an added case when querying an enum.
}

"""
Expand Down
9 changes: 7 additions & 2 deletions modules/service/src/main/scala/lucuma/odb/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,13 @@ object FMain extends MainParams {
}

def runStartupDiagnostics[F[_]: Async : Console : Network: Logger](config: Config.Database, fatal: Boolean): F[Unit] =
singleSession(config).map(StartupDiagnostics.apply(_)).use: sd =>
sd.runAllDiagnostics(fatal)
import lucuma.odb.graphql.util.SchemaSemigroup.*
singleSession(config).use: db =>
for
es <- Enums.load(db)
s = OdbMapping.unsafeLoadOdbSchema |+| es.schema
_ <- StartupDiagnostics(db, s, es).runAllDiagnostics(fatal)
yield ()

implicit def kleisliLogger[F[_]: Logger, A]: Logger[Kleisli[F, A, *]] =
Logger[F].mapK(Kleisli.liftK)
Expand Down
218 changes: 193 additions & 25 deletions modules/service/src/main/scala/lucuma/odb/StartupDiagnostics.scala

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import lucuma.odb.graphql.util.SchemaSemigroup

trait BaseMapping[F[_]]
extends SkunkMapping[F]
with SchemaSemigroup[F]
with SchemaSemigroup
with MappingExtras[F]
with CirceMappingLike[F] {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@ object OdbMapping {
}

// Loads a GraphQL file from the classpath, relative to this Class.
def unsafeLoadSchema(fileName: String): Schema = {
private def unsafeLoadSchema(fileName: String): Schema = {
val stream = getClass.getResourceAsStream(fileName)
val src = Source.fromInputStream(stream, "UTF-8")
try Schema(src.getLines().mkString("\n")).toEither.fold(x => sys.error(s"Invalid schema: $fileName: ${x.toList.mkString(", ")}"), identity)
finally src.close()
}

def unsafeLoadOdbSchema: Schema =
unsafeLoadSchema("OdbSchema.graphql")

private implicit def monoidPartialFunction[A, B]: Monoid[PartialFunction[A, B]] =
Monoid.instance(PartialFunction.empty, _ orElse _)

Expand Down Expand Up @@ -295,7 +298,7 @@ object OdbMapping {

// Our schema
val schema: Schema =
schema0.getOrElse(unsafeLoadSchema("OdbSchema.graphql") |+| enums.schema)
schema0.getOrElse(unsafeLoadOdbSchema |+| enums.schema)

// Our services and resources needed by various mappings.
override val commitHash = commitHash0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import cats.Semigroup
import cats.syntax.all.*
import grackle.DirectiveDef
import grackle.EnumType
import grackle.Mapping
import grackle.NamedType
import grackle.ObjectType
import grackle.Schema
import grackle.Type
import org.tpolecat.sourcepos.SourcePos

/** A mixin that provides Semigroup[Schema]. */
trait SchemaSemigroup[F[_]] extends Mapping[F] {
trait SchemaSemigroup {

private implicit val SemigroupDirectiveDef: Semigroup[DirectiveDef] = (a, b) =>
if (a.name != b.name) a
Expand Down Expand Up @@ -77,5 +76,5 @@ trait SchemaSemigroup[F[_]] extends Mapping[F] {

}


object SchemaSemigroup extends SchemaSemigroup

Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ class observation_configuration extends OdbSuite with ObservingModeSetupOperatio
"target" : {
"coordinates" : {
"ra" : {
"hms" : "08:09:46.797666"
"hms" : "08:09:46.797665"
}
},
"region" : null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@

package lucuma.odb.service

import cats.syntax.semigroup.*
import lucuma.odb.StartupDiagnostics
import lucuma.odb.graphql.OdbMapping
import lucuma.odb.graphql.OdbSuite
import lucuma.odb.graphql.enums.Enums
import lucuma.odb.graphql.util.SchemaSemigroup

class StartupDiagnosticsSuite extends OdbSuite:
class StartupDiagnosticsSuite extends OdbSuite with SchemaSemigroup:

val validUsers = Nil

// This ensures that diagnostics must pass in CI
test("run diagnostics"):
withSession: s =>
StartupDiagnostics(s).runAllDiagnostics(true)
withSession: db =>
for
es <- Enums.load(db)
s = OdbMapping.unsafeLoadOdbSchema |+| es.schema
_ <- StartupDiagnostics(db, s, es).runAllDiagnostics(true)
yield ()