Skip to content

Commit

Permalink
Fix services.
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjayVas committed Jun 30, 2023
1 parent a2a0a31 commit 526334b
Show file tree
Hide file tree
Showing 43 changed files with 296 additions and 404 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,3 @@ kt_jvm_library(
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common",
],
)

kt_jvm_library(
name = "time_intervals",
srcs = ["TimeIntervals.kt"],
deps = [
"//src/main/proto/wfa/measurement/api/v2alpha:requisition_spec_kt_jvm_proto",
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common",
],
)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
package org.wfanet.measurement.api.v2alpha.tools

import com.google.protobuf.ByteString
import com.google.type.interval
import io.grpc.ManagedChannel
import java.io.File
import java.security.SecureRandom
Expand Down Expand Up @@ -87,7 +88,6 @@ import org.wfanet.measurement.api.v2alpha.getMeasurementRequest
import org.wfanet.measurement.api.v2alpha.measurement
import org.wfanet.measurement.api.v2alpha.measurementSpec
import org.wfanet.measurement.api.v2alpha.requisitionSpec
import org.wfanet.measurement.api.v2alpha.timeInterval
import org.wfanet.measurement.api.withAuthenticationKey
import org.wfanet.measurement.common.commandLineMain
import org.wfanet.measurement.common.crypto.Hashing
Expand Down Expand Up @@ -413,7 +413,7 @@ private fun getDataProviderEntry(
eventGroupEntry {
key = it.name
value = eventGroupEntryValue {
collectionInterval = timeInterval {
collectionInterval = interval {
startTime = it.eventStartTime.toProtoTime()
endTime = it.eventEndTime.toProtoTime()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.google.crypto.tink.BinaryKeysetReader
import com.google.crypto.tink.CleartextKeysetHandle
import com.google.protobuf.ByteString
import com.google.protobuf.kotlin.toByteString
import com.google.type.interval
import io.grpc.ManagedChannel
import java.io.File
import java.security.SecureRandom
Expand Down Expand Up @@ -125,7 +126,6 @@ import org.wfanet.measurement.api.v2alpha.scheduleModelRolloutFreezeRequest
import org.wfanet.measurement.api.v2alpha.setModelLineActiveEndTimeRequest
import org.wfanet.measurement.api.v2alpha.setModelLineHoldbackModelLineRequest
import org.wfanet.measurement.api.v2alpha.signedData
import org.wfanet.measurement.api.v2alpha.timeInterval
import org.wfanet.measurement.api.v2alpha.updatePublicKeyRequest
import org.wfanet.measurement.api.withAuthenticationKey
import org.wfanet.measurement.api.withIdToken
Expand Down Expand Up @@ -860,7 +860,7 @@ class CreateMeasurement : Runnable {
key = it.name
value =
EventGroupEntries.value {
collectionInterval = timeInterval {
collectionInterval = interval {
startTime = it.eventStartTime.toProtoTime()
endTime = it.eventEndTime.toProtoTime()
}
Expand Down Expand Up @@ -1505,7 +1505,7 @@ private class ModelOutages {
val request = createModelOutageRequest {
parent = modelLineName
modelOutage = modelOutage {
outageInterval = timeInterval {
outageInterval = interval {
startTime = outageStartTime.toProtoTime()
endTime = outageEndTime.toProtoTime()
}
Expand Down Expand Up @@ -1574,7 +1574,7 @@ private class ModelOutages {
if (outageStartTime != null && outageEndTime != null) {
filter =
ListModelOutagesRequestKt.filter {
outageIntervalOverlapping = timeInterval {
outageIntervalOverlapping = interval {
startTime = outageStartTime.toProtoTime()
endTime = outageEndTime.toProtoTime()
}
Expand Down Expand Up @@ -1780,7 +1780,7 @@ private class ModelRollouts {
if (instantRolloutTime != null) {
this.instantRolloutTime = instantRolloutTime.toProtoTime()
} else {
gradualRolloutPeriod = timeInterval {
gradualRolloutPeriod = interval {
startTime = rolloutStartTime!!.toProtoTime()
endTime = rolloutEndTime!!.toProtoTime()
}
Expand Down Expand Up @@ -1842,7 +1842,7 @@ private class ModelRollouts {
if (rolloutPeriodStartTime != null && rolloutPeriodEndTime != null) {
filter =
ListModelRolloutsRequestKt.filter {
rolloutPeriodOverlapping = timeInterval {
rolloutPeriodOverlapping = interval {
startTime = rolloutPeriodStartTime.toProtoTime()
endTime = rolloutPeriodEndTime.toProtoTime()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ kt_jvm_library(
name = "privacy_query_mapper",
srcs = glob(["*.kt"]),
deps = [
"//src/main/kotlin/org/wfanet/measurement/api/v2alpha:time_intervals",
"//src/main/kotlin/org/wfanet/measurement/eventdataprovider/eventfiltration:event_filters",
"//src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement:privacy_budget_manager",
"//src/main/proto/wfa/measurement/api/v2alpha:measurement_spec_kt_jvm_proto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package org.wfanet.measurement.eventdataprovider.privacybudgetmanagement.api.v2a
import org.wfanet.measurement.api.v2alpha.MeasurementSpec
import org.wfanet.measurement.api.v2alpha.MeasurementSpec.MeasurementTypeCase
import org.wfanet.measurement.api.v2alpha.RequisitionSpec
import org.wfanet.measurement.api.v2alpha.toRange
import org.wfanet.measurement.common.toRange
import org.wfanet.measurement.eventdataprovider.privacybudgetmanagement.DpCharge
import org.wfanet.measurement.eventdataprovider.privacybudgetmanagement.EventGroupSpec
import org.wfanet.measurement.eventdataprovider.privacybudgetmanagement.LandscapeMask
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.wfanet.measurement.kingdom.service.api.v2alpha

import com.google.protobuf.util.Timestamps
import com.google.type.interval
import org.wfanet.measurement.api.Version
import org.wfanet.measurement.api.v2alpha.DataProviderCertificateKey
import org.wfanet.measurement.api.v2alpha.DataProviderKey
Expand Down Expand Up @@ -77,7 +78,6 @@ import org.wfanet.measurement.api.v2alpha.modelShard
import org.wfanet.measurement.api.v2alpha.modelSuite
import org.wfanet.measurement.api.v2alpha.protocolConfig
import org.wfanet.measurement.api.v2alpha.signedData
import org.wfanet.measurement.api.v2alpha.timeInterval
import org.wfanet.measurement.common.identity.apiIdToExternalId
import org.wfanet.measurement.common.identity.externalIdToApiId
import org.wfanet.measurement.common.toLocalDate
Expand Down Expand Up @@ -404,7 +404,7 @@ fun InternalModelOutage.toModelOutage(): ModelOutage {
externalIdToApiId(source.externalModelOutageId)
)
.toName()
outageInterval = timeInterval {
outageInterval = interval {
startTime = source.modelOutageStartTime
endTime = source.modelOutageEndTime
}
Expand Down Expand Up @@ -444,7 +444,7 @@ fun InternalModelRollout.toModelRollout(): ModelRollout {
if (Timestamps.compare(source.rolloutPeriodStartTime, source.rolloutPeriodEndTime) == 0) {
instantRolloutTime = source.rolloutPeriodStartTime
} else {
gradualRolloutPeriod = timeInterval {
gradualRolloutPeriod = interval {
startTime = source.rolloutPeriodStartTime
endTime = source.rolloutPeriodEndTime
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ kt_jvm_library(
"//imports/java/com/google:cel-generated-pb",
"//imports/java/org/projectnessie/cel",
"//src/main/kotlin/org/wfanet/measurement/api/v2alpha:resource_key",
"//src/main/kotlin/org/wfanet/measurement/api/v2alpha:time_intervals",
"//src/main/kotlin/org/wfanet/measurement/eventdataprovider/eventfiltration:event_filters",
"//src/main/kotlin/org/wfanet/measurement/eventdataprovider/noiser",
"//src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement:privacy_budget_manager",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import com.google.cloud.bigquery.JobId
import com.google.cloud.bigquery.JobInfo
import com.google.cloud.bigquery.QueryJobConfiguration
import com.google.cloud.bigquery.QueryParameterValue
import com.google.type.Interval
import java.time.Instant
import java.time.temporal.ChronoUnit
import java.util.UUID
import java.util.logging.Logger
import org.wfanet.measurement.api.v2alpha.RequisitionSpec.EventFilter
import org.wfanet.measurement.api.v2alpha.TimeInterval
import org.wfanet.measurement.api.v2alpha.event_templates.testing.Person
import org.wfanet.measurement.api.v2alpha.event_templates.testing.PersonKt
import org.wfanet.measurement.api.v2alpha.event_templates.testing.TestEvent
Expand All @@ -47,10 +47,7 @@ class BigQueryEventQuery(
private val publisherId: Int,
) : EventQuery {

override fun getUserVirtualIds(
timeInterval: TimeInterval,
eventFilter: EventFilter
): Sequence<Long> {
override fun getUserVirtualIds(timeInterval: Interval, eventFilter: EventFilter): Sequence<Long> {
val queryConfig =
buildQueryConfig(
publisherId = publisherId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
package org.wfanet.measurement.loadtest.dataprovider

import com.google.protobuf.Descriptors
import com.google.type.Interval
import org.projectnessie.cel.Program
import org.projectnessie.cel.common.types.BoolT
import org.wfanet.measurement.api.v2alpha.RequisitionSpec.EventFilter
import org.wfanet.measurement.api.v2alpha.TimeInterval
import org.wfanet.measurement.eventdataprovider.eventfiltration.EventFilters

/** A query to get the list of user virtual IDs for a particular requisition. */
Expand All @@ -29,7 +29,7 @@ interface EventQuery {
* Each element in the returned value represents a single event. As a result, the same VID may be
* returned multiple times.
*/
fun getUserVirtualIds(timeInterval: TimeInterval, eventFilter: EventFilter): Sequence<Long>
fun getUserVirtualIds(timeInterval: Interval, eventFilter: EventFilter): Sequence<Long>

companion object {
private val TRUE_EVAL_RESULT = Program.newEvalResult(BoolT.True, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
*/
package org.wfanet.measurement.loadtest.dataprovider

import com.google.type.Interval
import org.wfanet.measurement.api.v2alpha.RequisitionSpec
import org.wfanet.measurement.api.v2alpha.TimeInterval
import org.wfanet.measurement.api.v2alpha.event_templates.testing.TestEvent
import org.wfanet.measurement.api.v2alpha.event_templates.testing.timeOrNull
import org.wfanet.measurement.api.v2alpha.toRange
import org.wfanet.measurement.common.toInstant
import org.wfanet.measurement.common.toRange
import org.wfanet.measurement.eventdataprovider.eventfiltration.EventFilters

/** Fulfills the query with matching events using filters. */
Expand All @@ -30,7 +30,7 @@ open class InMemoryEventQuery(private val events: Iterable<LabelledEvent>) : Eve
data class LabelledEvent(val vid: Long, val event: TestEvent)

override fun getUserVirtualIds(
timeInterval: TimeInterval,
timeInterval: Interval,
eventFilter: RequisitionSpec.EventFilter
): Sequence<Long> {
val timeRange = timeInterval.toRange()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

package org.wfanet.measurement.loadtest.dataprovider

import com.google.type.Interval
import java.util.logging.Logger
import kotlin.random.Random
import org.wfanet.measurement.api.v2alpha.RequisitionSpec.EventFilter
import org.wfanet.measurement.api.v2alpha.TimeInterval

data class SketchGenerationParams(
val reach: Int,
Expand All @@ -28,10 +28,7 @@ data class SketchGenerationParams(
class RandomEventQuery(private val sketchGenerationParams: SketchGenerationParams) : EventQuery {

/** Returns VIDs generated from random values, ignoring [timeInterval] and [eventFilter]. */
override fun getUserVirtualIds(
timeInterval: TimeInterval,
eventFilter: EventFilter
): Sequence<Long> {
override fun getUserVirtualIds(timeInterval: Interval, eventFilter: EventFilter): Sequence<Long> {
// TODO(@alberthsuu): Generate eventId, deduplicate the list of (eventId, vid), and
// return the vids in case eventGroups overlap in some way

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package org.wfanet.measurement.loadtest.frontend

import com.google.common.truth.Truth.assertThat
import com.google.protobuf.ByteString
import com.google.type.interval
import io.grpc.StatusException
import java.nio.file.Paths
import java.security.SignatureException
Expand Down Expand Up @@ -81,7 +82,6 @@ import org.wfanet.measurement.api.v2alpha.measurement
import org.wfanet.measurement.api.v2alpha.measurementSpec
import org.wfanet.measurement.api.v2alpha.requisitionSpec
import org.wfanet.measurement.api.v2alpha.testing.MeasurementResultSubject.Companion.assertThat
import org.wfanet.measurement.api.v2alpha.timeInterval
import org.wfanet.measurement.api.withAuthenticationKey
import org.wfanet.measurement.common.OpenEndTimeRange
import org.wfanet.measurement.common.crypto.Hashing
Expand Down Expand Up @@ -674,7 +674,7 @@ class FrontendSimulator(
key = eventGroup.name
value =
RequisitionSpecKt.EventGroupEntryKt.value {
collectionInterval = timeInterval {
collectionInterval = interval {
startTime = EVENT_RANGE.start.toProtoTime()
endTime = EVENT_RANGE.endExclusive.toProtoTime()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.wfanet.measurement.reporting.deploy.v2.postgres.readers

import com.google.type.Interval
import com.google.type.interval
import java.time.Instant
import java.util.UUID
import kotlinx.coroutines.flow.Flow
Expand All @@ -29,9 +31,7 @@ import org.wfanet.measurement.common.identity.InternalId
import org.wfanet.measurement.common.toProtoTime
import org.wfanet.measurement.internal.reporting.v2.Measurement
import org.wfanet.measurement.internal.reporting.v2.ReportingSetKt
import org.wfanet.measurement.internal.reporting.v2.TimeInterval
import org.wfanet.measurement.internal.reporting.v2.measurement
import org.wfanet.measurement.internal.reporting.v2.timeInterval

class MeasurementReader(private val readContext: ReadContext) {
data class Result(
Expand All @@ -45,7 +45,7 @@ class MeasurementReader(private val readContext: ReadContext) {
val cmmsMeasurementConsumerId: String,
val cmmsMeasurementId: String?,
val cmmsCreateMeasurementRequestId: String,
val timeInterval: TimeInterval,
val timeInterval: Interval,
// Key is primitiveReportingSetBasisId.
val primitiveReportingSetBasisInfoMap: MutableMap<InternalId, PrimitiveReportingSetBasisInfo>,
val state: Measurement.State,
Expand Down Expand Up @@ -220,7 +220,7 @@ class MeasurementReader(private val readContext: ReadContext) {

val measurementInfo =
measurementInfoMap.computeIfAbsent(measurementId) {
val timeInterval = timeInterval {
val timeInterval = interval {
startTime = measurementTimeIntervalStart.toProtoTime()
endTime = measurementTimeIntervalEnd.toProtoTime()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.wfanet.measurement.reporting.deploy.v2.postgres.readers

import com.google.protobuf.Timestamp
import com.google.type.Interval
import com.google.type.interval
import java.time.Instant
import java.util.UUID
import kotlinx.coroutines.flow.Flow
Expand All @@ -36,11 +38,9 @@ import org.wfanet.measurement.internal.reporting.v2.MetricSpec
import org.wfanet.measurement.internal.reporting.v2.MetricSpecKt
import org.wfanet.measurement.internal.reporting.v2.ReportingSetKt
import org.wfanet.measurement.internal.reporting.v2.StreamMetricsRequest
import org.wfanet.measurement.internal.reporting.v2.TimeInterval
import org.wfanet.measurement.internal.reporting.v2.measurement
import org.wfanet.measurement.internal.reporting.v2.metric
import org.wfanet.measurement.internal.reporting.v2.metricSpec
import org.wfanet.measurement.internal.reporting.v2.timeInterval

class MetricReader(private val readContext: ReadContext) {
data class Result(
Expand All @@ -58,7 +58,7 @@ class MetricReader(private val readContext: ReadContext) {
val metricId: InternalId,
val externalMetricId: String,
val createTime: Timestamp,
val timeInterval: TimeInterval,
val timeInterval: Interval,
val metricSpec: MetricSpec,
val weightedMeasurementInfoMap: MutableMap<MetricMeasurementKey, WeightedMeasurementInfo>,
val details: Metric.Details,
Expand All @@ -78,7 +78,7 @@ class MetricReader(private val readContext: ReadContext) {
private data class MeasurementInfo(
val cmmsMeasurementId: String?,
val cmmsCreateMeasurementRequestId: String,
val timeInterval: TimeInterval,
val timeInterval: Interval,
// Key is primitiveReportingSetBasisId.
val primitiveReportingSetBasisInfoMap: MutableMap<InternalId, PrimitiveReportingSetBasisInfo>,
val state: Measurement.State,
Expand Down Expand Up @@ -389,7 +389,7 @@ class MetricReader(private val readContext: ReadContext) {

val metricInfo =
metricInfoMap.computeIfAbsent(externalMetricId) {
val metricTimeInterval = timeInterval {
val metricTimeInterval = interval {
startTime = metricTimeIntervalStart.toProtoTime()
endTime = metricTimeIntervalEnd.toProtoTime()
}
Expand Down Expand Up @@ -493,7 +493,7 @@ class MetricReader(private val readContext: ReadContext) {
metricId = metricId,
)
) {
val timeInterval = timeInterval {
val timeInterval = interval {
startTime = measurementTimeIntervalStart.toProtoTime()
endTime = measurementTimeIntervalEnd.toProtoTime()
}
Expand Down
Loading

0 comments on commit 526334b

Please sign in to comment.