Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update population spec converter #2013

Open
wants to merge 78 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
2e39cf0
Create Population Requisition Fulfiller Daemon.
Sep 18, 2024
95fe17f
Merge branch 'main' into jojijacob-create-population-requisition-fulf…
Sep 19, 2024
37c4d33
Lint
Sep 19, 2024
c64d3eb
Lint
Sep 19, 2024
39b532b
Lint
Sep 19, 2024
50fb3a0
Add license header
Sep 19, 2024
ca6a28b
Use ArgGroup instead of Map for the input of population info. Remove …
Sep 24, 2024
4a88417
Merge branch 'main' into jojijacob-create-population-requisition-fulf…
Nov 20, 2024
fb64528
Replace eventMessageDescriptorFile to eventMessageTypeUrl in Populati…
Nov 21, 2024
277bdc8
Remove unnecessary line in PopulationRequisitionFulfiller.
Nov 21, 2024
0a45475
Merge.
Nov 21, 2024
076c3c9
Create PopulationRequisitionFulfillerDaemon image and add it to image…
Nov 27, 2024
e4d5cda
Modify CUE files.
Dec 3, 2024
b197ca7
Add java_image import to PopulationRequisitionFulfillerDaemon BUILD f…
Dec 3, 2024
0af7427
Create resources in ResourceSetup.
Dec 3, 2024
0fbe9dc
Add population data provider name and model name to resources.proto s…
Dec 4, 2024
a33f36a
Add internal service parameters to instantiation of ResourceSetup cla…
Dec 5, 2024
4de7184
Assign values to modelLineName and populationDataProvider variables.
Dec 5, 2024
3ce2ecd
test.
Dec 16, 2024
fdd2c8b
add population requisition fulfiller image to scan-images.yml
Dec 16, 2024
cf0b04b
Add population_requisition_fulfillers to build files
Dec 17, 2024
2aec561
Change CUE file to server deployment.
Dec 17, 2024
acb34e8
merge
Dec 17, 2024
bf43cc6
test
Dec 17, 2024
92baa3b
add population_requisition_fulfillers_cue to build file
Dec 17, 2024
3820f7b
add population_requisition_fulfillers_cue to build file
Dec 17, 2024
6762470
fix error in CUE file
Dec 17, 2024
c5602b5
fix error in CUE file
Dec 17, 2024
9e1fba1
fix error in CUE files
Dec 17, 2024
c51b7d0
fix error in population_requisition_fulfillers.cue
Dec 17, 2024
4a0afd4
fix cue files
Dec 17, 2024
aea6473
fix cue files
Dec 17, 2024
80e5775
resolve cue file error
Dec 17, 2024
1281d5f
test
Dec 17, 2024
0cfea71
test
Dec 17, 2024
a10c0d2
fix cue file
Dec 17, 2024
987ec3c
cue file fix.
Dec 18, 2024
0aae0cc
fix cue file to not wait on anything.
Dec 18, 2024
5ff349a
test
Dec 18, 2024
1837951
refactor cue files
Dec 18, 2024
9b24d0b
fix cue file.
Dec 18, 2024
a80b09e
add required flags to cue file.
Dec 19, 2024
cf746fe
create pb files to be used in test.
Dec 19, 2024
4ee117a
add new population_spect textproto to test with
Dec 20, 2024
5b2d59b
use correct public api channel
Dec 20, 2024
c4f7a27
add pdp to akid map in resource setup
Jan 7, 2025
66b4bbb
use correct population spec in cue file.
Jan 7, 2025
19b1a34
fix test expected result
Jan 7, 2025
194c239
fix test
Jan 7, 2025
517e32e
fix bug in modellineresourcename being set.
Jan 7, 2025
2b5ade5
clean up code
Jan 7, 2025
51a4051
remove unneccessary imports in build file.
Jan 8, 2025
2179870
add imports to build file.
Jan 8, 2025
9c90594
remove imports from build file.
Jan 8, 2025
3df3581
set auth files for resource setup runner in script.
Jan 8, 2025
dfa58cf
Change repository name of population_requisition_fulfiller_image stru…
Jan 14, 2025
089c011
Update CUE file to reflect change made in images.bzl. Remove unnecces…
Jan 15, 2025
78fcd20
Use small population spec instead of large population spec.
Jan 15, 2025
dcea31b
Update yaml files to use population_spec_small
Jan 15, 2025
a34f6c5
Update test with small population spec
Jan 15, 2025
660f0a8
Remove synthetic_population_spec_small.textproto from dev config yaml…
Jan 16, 2025
4645602
Remove population_spec_large
Jan 16, 2025
73c4911
Rename test_event_type_set to test_event_message_descriptor_set.
Jan 16, 2025
59fda01
Remove unnecessary imports in bazel and yaml files
Jan 16, 2025
657ebd8
Update scan-images.yaml with updated image repository for population …
Jan 16, 2025
fdec56c
Add missing source in build file.
Jan 16, 2025
bb028eb
Create CUE files for PopulationRequisitionFulfiller. Fix bugs in Pop…
Jan 17, 2025
7a97415
Add pdp settings to TEST_K8S_SETTINGS struct.
Jan 17, 2025
695d6ff
Merge.
Jan 17, 2025
533cab5
Update build file.
Jan 17, 2025
f26eb17
Remove source in build file.
Jan 17, 2025
1b3a0f5
Update PopulationSpecConverter to include attributes in the subpopula…
Jan 17, 2025
9119d94
Add population requisition fulfiller daemon docker image to images.bzl
Jan 17, 2025
32e89a3
Merge branch 'jojijacob-create-pdp-cue-files' into jojijacob-update-p…
Jan 17, 2025
d14f4c3
Add java_binary and java_image rules to population requisition fulfil…
Jan 17, 2025
0a44887
Merge branch 'jojijacob-create-pdp-cue-files' into jojijacob-update-p…
Jan 17, 2025
4af2b2c
Add data-provider/population-requisition-fulfiller image to scan-imag…
Jan 17, 2025
ec79c11
Merge branch 'jojijacob-create-pdp-cue-files' into jojijacob-update-p…
Jan 17, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/scan-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ jobs:
- duchy/aws-postgres-internal-server
- panel-exchange/forwarded-storage-daemon
- prober/measurement-system-prober
- data-provider/population-requisition-fulfiller
steps:
- name: Get SARIF file path
id: get-sarif-file-path
Expand Down
3 changes: 3 additions & 0 deletions build/variables.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ TEST_K8S_SETTINGS = struct(
db_secret_name = "$(k8s_db_secret_name)",
mc_config_secret_name = "$(k8s_mc_config_secret_name)",
grafana_secret_name = "$(k8s_grafana_secret_name)",
pdp1_name = "$(pdp1_name)",
pdp1_cert_name = "$(pdp1_cert_name)",
population_resource_name = "$(population_resource_name)",
)

GCLOUD_SETTINGS = struct(
Expand Down
5 changes: 5 additions & 0 deletions src/main/docker/images.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ COMMON_IMAGES = [
image = "//src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider:synthetic_generator_edp_simulator_runner_image",
repository = _PREFIX + "/simulator/synthetic-generator-edp",
),
struct(
name = "population_requisition_fulfiller_image",
image = "//src/main/kotlin/org/wfanet/measurement/populationdataprovider:population_requisition_fulfiller_daemon_image",
repository = _PREFIX + "/data-provider/population-requisition-fulfiller",
),
struct(
name = "access_public_api_server_image",
image = "//src/main/kotlin/org/wfanet/measurement/access/deploy/common/server:public_api_server_image",
Expand Down
9 changes: 9 additions & 0 deletions src/main/k8s/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,12 @@ cue_library(
":spanner",
],
)

cue_library(
name = "population_requisition_fulfiller",
srcs = ["population_requisition_fulfiller.cue"],
deps = [
":base",
":config",
],
)
28 changes: 28 additions & 0 deletions src/main/k8s/local/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,33 @@ cue_dump(
],
)

cue_library(
name = "population_requisition_fulfillers_cue",
srcs = ["population_requisition_fulfillers.cue"],
deps = [
":config_cue",
"//src/main/k8s:population_requisition_fulfiller",
],
)

cue_dump(
name = "population_requisition_fulfillers",
cue_tags = {
"secret_name": SECRET_NAME,
"container_registry": IMAGE_REPOSITORY_SETTINGS.container_registry,
"image_repo_prefix": IMAGE_REPOSITORY_SETTINGS.repository_prefix,
"image_tag": IMAGE_REPOSITORY_SETTINGS.image_tag,
"mc_name": TEST_K8S_SETTINGS.mc_name,
"pdp1_name": TEST_K8S_SETTINGS.pdp1_name,
"pdp1_cert_name": TEST_K8S_SETTINGS.pdp1_cert_name,
"population_resource_name": TEST_K8S_SETTINGS.population_resource_name,
},
tags = ["manual"],
deps = [
":population_requisition_fulfillers_cue",
],
)

cue_library(
name = "measurement_system_prober_cue",
srcs = ["measurement_system_prober.cue"],
Expand Down Expand Up @@ -386,6 +413,7 @@ kustomization_dir(
":emulators",
":kingdom",
":measurement_system_prober",
":population_requisition_fulfillers",
":postgres_database",
],
generate_kustomization = True,
Expand Down
53 changes: 53 additions & 0 deletions src/main/k8s/local/population_requisition_fulfillers.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2024 The Cross-Media Measurement Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package k8s

_mc_name: string @tag("mc_name")
_pdp1_name: string @tag("pdp1_name")
_pdp1_cert_name: string @tag("pdp1_cert_name")
_population_resource_name: string @tag("population_resource_name")
_secret_name: string @tag("secret_name")


_populationSpec: "/etc/\(#AppName)/config-files/population_spec_small.textproto"
_populationRequisitionFulfillerConfigs: [...#PopulationRequisitionFulfillerConfig]
_populationRequisitionFulfillerConfigs: [
{
dataProviderDisplayName: "pdp1"
dataProviderResourceName: _pdp1_name
dataProviderCertResourceName: _pdp1_cert_name
populationKeyAndInfoList: [
{
populationResourceName: _population_resource_name
populationSpecFile: _populationSpec
eventMessageTypeUrl: "type.googleapis.com/wfa.measurement.api.v2alpha.event_templates.testing.TestEvent"
}
]
eventMessageDescriptorSet: ["/etc/\(#AppName)/config-files/person_type_set.pb", "/etc/\(#AppName)/config-files/test_event_message_descriptor_set.pb"]
}
]

objectSets: [ for fulfiller in populationRequisitionFulfillers {[fulfiller.deployment]}] +
[ for fulfiller in populationRequisitionFulfillers {fulfiller.networkPolicies}]

populationRequisitionFulfillers: {
for config in _populationRequisitionFulfillerConfigs {
"\(config.dataProviderDisplayName)": #PopulationRequisitionFulfiller & {
_imageConfig: repoSuffix: "data-provider/population-requisition-fulfiller"
_populationRequisitionFulfillerSecretName: _secret_name
_config: config
}
}
}
104 changes: 104 additions & 0 deletions src/main/k8s/population_requisition_fulfiller.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Copyright 2024 The Cross-Media Measurement Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package k8s

import "list"


#KingdomPublicApiTarget: (#Target & {name: "v2alpha-public-api-server"}).target

#PopulationRequisitionFulfillerConfig: {
dataProviderDisplayName: string
dataProviderResourceName: string
dataProviderCertResourceName: string
throttlerMinimumInterval: string | *"2s"
eventMessageDescriptorSet: [...string]
populationKeyAndInfoList: [...#PopulationKeyAndInfo]
}

#PopulationKeyAndInfo: {
populationResourceName: string
populationSpecFile: string
eventMessageTypeUrl: string
}

#PopulationRequisitionFulfiller: {
_config: #PopulationRequisitionFulfillerConfig
_imageConfig: #ImageConfig
_populationRequisitionFulfillerSecretName: string

let displayName = _config.dataProviderDisplayName

_populationFlags: {
let flagLists = [ for config in _config.populationKeyAndInfoList {[
"--population-resource-name=\(config.populationResourceName)",
"--population-spec=\(config.populationSpecFile)",
"--event-message-type-url=\(config.eventMessageTypeUrl)",
]}]
list.FlattenN(flagLists, 2)
}

_eventDescriptorFlags: {
let flagLists = [ for file in _config.eventMessageDescriptorSet {[
"--event-message-descriptor-set=\(file)"
]}]
list.FlattenN(flagLists, 2)
}

deployment: #Deployment & {
_name: displayName + "-simulator"
_secretName: _populationRequisitionFulfillerSecretName
_system: "population"
_container: {
image: _imageConfig.image
args: [
"--kingdom-public-api-target=\(#KingdomPublicApiTarget)",
"--kingdom-public-api-cert-host=localhost",
"--data-provider-resource-name=\(_config.dataProviderResourceName)",
"--data-provider-display-name=\(displayName)",
"--data-provider-certificate-resource-name=\(_config.dataProviderCertResourceName)",
"--data-provider-encryption-private-keyset=/var/run/secrets/files/\(displayName)_enc_private.tink",
"--data-provider-consent-signaling-private-key-der-file=/var/run/secrets/files/\(displayName)_cs_private.der",
"--data-provider-consent-signaling-certificate-der-file=/var/run/secrets/files/\(displayName)_cs_cert.der",
"--throttler-minimum-interval=\(_config.throttlerMinimumInterval)",
"--tls-cert-file=/var/run/secrets/files/\(displayName)_root.pem",
"--tls-key-file=/var/run/secrets/files/\(displayName)_root.key",
"--cert-collection-file=/var/run/secrets/files/all_root_certs.pem",
] + _populationFlags + _eventDescriptorFlags
}
spec: template: spec: {
_dependencies: [
"v2alpha-public-api-server",
"worker1-requisition-fulfillment-server",
"worker2-requisition-fulfillment-server",
]
_mounts: "config-files": #ConfigMapMount
}
}

networkPolicies: [Name=_]: #NetworkPolicy & {
_name: Name
}

networkPolicies: {
"\(deployment._name)": {
_app_label: deployment.spec.template.metadata.labels.app
_egresses: {
// Need to be able to access Kingdom.
any: {}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,7 @@ kt_jvm_library(
deps = [
"//src/main/proto/wfa/measurement/api/v2alpha:population_spec_kt_jvm_proto",
"//src/main/proto/wfa/measurement/api/v2alpha/event_group_metadata/testing:simulator_synthetic_data_spec_kt_jvm_proto",
"//src/main/proto/wfa/measurement/api/v2alpha/event_templates/testing:test_event_kt_jvm_proto",
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import org.wfanet.measurement.api.v2alpha.PopulationSpec
import org.wfanet.measurement.api.v2alpha.PopulationSpecKt.subPopulation
import org.wfanet.measurement.api.v2alpha.PopulationSpecKt.vidRange
import org.wfanet.measurement.api.v2alpha.event_group_metadata.testing.SyntheticPopulationSpec
import org.wfanet.measurement.api.v2alpha.event_templates.testing.Person
import org.wfanet.measurement.api.v2alpha.event_templates.testing.person
import org.wfanet.measurement.api.v2alpha.populationSpec
import org.wfanet.measurement.common.pack

fun SyntheticPopulationSpec.toPopulationSpec(): PopulationSpec {
return populationSpec {
Expand All @@ -31,6 +34,11 @@ fun SyntheticPopulationSpec.toPopulationSpec(): PopulationSpec {
startVid = it.vidSubRange.start
endVidInclusive = (it.vidSubRange.endExclusive - 1)
}
attributes += person {
gender = Person.Gender.forNumber(it.populationFieldsValuesMap["person.gender"]!!.enumValue)
ageGroup = Person.AgeGroup.forNumber(it.populationFieldsValuesMap["person.age_group"]!!.enumValue)
socialGradeGroup = Person.SocialGradeGroup.forNumber(it.populationFieldsValuesMap["person.social_grade_group"]!!.enumValue)
}.pack()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
load("@rules_java//java:defs.bzl", "java_binary")
load("@wfa_rules_kotlin_jvm//kotlin:defs.bzl", "kt_jvm_library")
load("//src/main/docker:macros.bzl", "java_image")

package(
default_visibility = [
Expand Down Expand Up @@ -44,3 +46,19 @@ kt_jvm_library(
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/storage:client",
],
)

java_binary(
name = "PopulationRequisitionFulfillerDaemon",
main_class = "org.wfanet.measurement.populationdataprovider.PopulationRequisitionFulfillerDaemonKt",
runtime_deps = [
":population_requisition_fulfiller_daemon",
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/gcloud/logging",
],
)

java_image(
name = "population_requisition_fulfiller_daemon_image",
binary = ":PopulationRequisitionFulfillerDaemon",
main_class = "org.wfanet.measurement.populationdataprovider.PopulationRequisitionFulfillerDaemonKt",
visibility = ["//src:docker_image_deployment"],
)
Loading
Loading