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

Protobuf Translation 1.0.0 #62

Merged
merged 33 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9067a5b
fix compile errors
bischoffz Mar 21, 2023
7426568
refactor of enum
bischoffz Mar 21, 2023
12bd4e7
rename
bischoffz Mar 22, 2023
27eb3d0
groupid update
bischoffz Mar 22, 2023
4271555
move folder
bischoffz Mar 22, 2023
7880986
move gitignore
bischoffz Mar 22, 2023
7e3f1c4
add back ignore sub gitignores
bischoffz Mar 22, 2023
4a1dff7
add vscode folder to gitignore
bischoffz Mar 22, 2023
83165bf
update demo with new changes
bischoffz Mar 22, 2023
79df00e
remove flattened-poms
bischoffz Mar 22, 2023
6891ab7
update gitignore
bischoffz Mar 22, 2023
9dcbf49
reorganization based on new groupid
bischoffz Mar 22, 2023
90c0872
update proto with new package
bischoffz Mar 22, 2023
eb6e826
update input imports
bischoffz Mar 22, 2023
f84f089
move app into test
bischoffz Mar 22, 2023
e8c4eff
groups translator basic test
bischoffz Mar 22, 2023
f9f7f44
refactor
bischoffz Mar 22, 2023
ff5fd02
add basic test for materials
bischoffz Mar 22, 2023
f61f16e
add basic test for simulation time
bischoffz Mar 22, 2023
4c75330
add basic test for people translator
bischoffz Mar 22, 2023
400cd2d
add basic test for person properties translator
bischoffz Mar 22, 2023
6a1529f
add basic test for properties plugin translator
bischoffz Mar 22, 2023
bb0b129
add basic test for regions translator
bischoffz Mar 22, 2023
73991ad
clean up imports
bischoffz Mar 22, 2023
9c720be
add basic test for resources translator
bischoffz Mar 22, 2023
b970982
move deep merge into util for safe keeping
bischoffz Mar 22, 2023
74ee986
add basic test for stochastics translator
bischoffz Mar 22, 2023
2013296
update tests to run with maven
bischoffz Mar 22, 2023
4ee35d8
add assembly jar to include all translators
bischoffz Mar 22, 2023
297cfff
update demo
bischoffz Mar 22, 2023
26d85e9
remove commented out code
bischoffz Mar 22, 2023
d406ff5
Merge branch 'dev' of https://github.com/HHS/ASPR-8 into translator-c…
bischoffz Mar 22, 2023
29028c5
1.0.0 RC
bischoffz Mar 22, 2023
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
5 changes: 4 additions & 1 deletion demos/demo1/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,7 @@ Temporary Items

###################################
# END MacOS
###################################
###################################


.vscode
34 changes: 2 additions & 32 deletions demos/demo1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,38 +62,8 @@
<version>${protobuf.version}</version>
</dependency>
<dependency>
<groupId>gov.hhs.aspr.gcm.translation</groupId>
<artifactId>core</artifactId>
<version>${gcm.proto-definitions.version}</version>
</dependency>
<dependency>
<groupId>gov.hhs.aspr.gcm.translation</groupId>
<artifactId>nucleus-translator</artifactId>
<version>${gcm.proto-definitions.version}</version>
</dependency>
<dependency>
<groupId>gov.hhs.aspr.gcm.translation</groupId>
<artifactId>regions-plugin-translator</artifactId>
<version>${gcm.proto-definitions.version}</version>
</dependency>
<dependency>
<groupId>gov.hhs.aspr.gcm.translation</groupId>
<artifactId>people-plugin-translator</artifactId>
<version>${gcm.proto-definitions.version}</version>
</dependency>
<dependency>
<groupId>gov.hhs.aspr.gcm.translation</groupId>
<artifactId>stochastics-plugin-translator</artifactId>
<version>${gcm.proto-definitions.version}</version>
</dependency>
<dependency>
<groupId>gov.hhs.aspr.gcm.translation</groupId>
<artifactId>globalproperties-plugin-translator</artifactId>
<version>${gcm.proto-definitions.version}</version>
</dependency>
<dependency>
<groupId>gov.hhs.aspr.gcm.translation</groupId>
<artifactId>personproperties-plugin-translator</artifactId>
<groupId>gov.hhs.aspr.gcm.translation.protobuf</groupId>
<artifactId>plugin-translators-all</artifactId>
<version>${gcm.proto-definitions.version}</version>
</dependency>
<dependency>
Expand Down
50 changes: 20 additions & 30 deletions demos/demo1/src/main/java/lesson/SerializationDemonstration.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

import org.apache.commons.math3.random.RandomGenerator;

import gov.hhs.aspr.gcm.translation.core.Translator;
import gov.hhs.aspr.gcm.translation.core.TranslatorController;
import gov.hhs.aspr.gcm.translation.plugins.globalproperties.GlobalPropertiesTranslator;
import gov.hhs.aspr.gcm.translation.plugins.people.PeopleTranslator;
import gov.hhs.aspr.gcm.translation.plugins.personproperties.PersonPropertiesTranslator;
import gov.hhs.aspr.gcm.translation.plugins.properties.PropertiesTranslator;
import gov.hhs.aspr.gcm.translation.plugins.regions.RegionsTranslator;
import gov.hhs.aspr.gcm.translation.plugins.stochastics.StochasticsTranslator;
import gov.hss.aspr.gcm.translation.nucleus.NucleusTranslator;
import gov.hhs.aspr.gcm.translation.protobuf.core.Translator;
import gov.hhs.aspr.gcm.translation.protobuf.core.TranslatorController;
import gov.hhs.aspr.gcm.translation.protobuf.plugins.globalproperties.GlobalPropertiesTranslator;
import gov.hhs.aspr.gcm.translation.protobuf.plugins.people.PeopleTranslator;
import gov.hhs.aspr.gcm.translation.protobuf.plugins.personproperties.PersonPropertiesTranslator;
import gov.hhs.aspr.gcm.translation.protobuf.plugins.properties.PropertiesTranslator;
import gov.hhs.aspr.gcm.translation.protobuf.plugins.regions.RegionsTranslator;
import gov.hhs.aspr.gcm.translation.protobuf.plugins.stochastics.StochasticsTranslator;
import gov.hss.aspr.gcm.translation.protobuf.nucleus.NucleusTranslator;
import lesson.plugins.model.GlobalProperty;
import lesson.plugins.model.ModelPlugin;
import lesson.plugins.model.ModelReportLabel;
Expand All @@ -42,14 +42,11 @@
import plugins.people.PeoplePluginData;
import plugins.personproperties.PersonPropertiesPlugin;
import plugins.personproperties.PersonPropertiesPluginData;
import plugins.personproperties.reports.PersonPropertyReport;
import plugins.personproperties.reports.PersonPropertyReportPluginData;
import plugins.regions.RegionsPlugin;
import plugins.regions.RegionsPluginData;
import plugins.reports.ReportsPlugin;
import plugins.reports.ReportsPluginData;
import plugins.reports.support.NIOReportItemHandler;
import plugins.reports.support.ReportPeriod;
import plugins.stochastics.StochasticsPlugin;
import plugins.stochastics.StochasticsPluginData;
import plugins.util.properties.PropertyDefinition;
Expand Down Expand Up @@ -84,23 +81,14 @@ private SerializationDemonstration(Path outputDirectory) {
.addTranslatorSpec(new PersonPropertyTranslatorSpec())
.addTranslatorSpec(new GlobalPropertyTranslatorSpec())
.addTranslatorSpec(new RegionTranslatorSpec())
.build().init();
.build();
}

private RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(524055747550937602L);

private Plugin getReportsPlugin() {
ReportsPluginData reportsPluginData = //
ReportsPluginData.builder()//
.addReport(() -> {
PersonPropertyReportPluginData personPropertyReportPluginData = PersonPropertyReportPluginData
.builder()//
.setReportLabel(ModelReportLabel.PERSON_PROPERTY_REPORT)//
.setReportPeriod(ReportPeriod.END_OF_SIMULATION)//
.setDefaultInclusion(true)//
.build();//
return new PersonPropertyReport(personPropertyReportPluginData)::init;
})//
.addReport(() -> {
return new VaccineReport(ModelReportLabel.VACCINATION)::init;
})//
Expand Down Expand Up @@ -154,7 +142,8 @@ private Plugin getPersonPropertiesPlugin() {
builder.definePersonProperty(PersonProperty.VACCINATED, propertyDefinition);

PersonPropertiesPluginData personPropertiesPluginData = builder.build();
return PersonPropertiesPlugin.getPersonPropertyPlugin(personPropertiesPluginData);
return PersonPropertiesPlugin.builder().setPersonPropertiesPluginData(personPropertiesPluginData)
.getPersonPropertyPlugin();
}

private Plugin getStochasticsPlugin() {
Expand Down Expand Up @@ -248,7 +237,8 @@ private Plugin getGlobalPropertiesPlugin() {

GlobalPropertiesPluginData globalPropertiesPluginData = builder.build();

return GlobalPropertiesPlugin.getGlobalPropertiesPlugin(globalPropertiesPluginData);
return GlobalPropertiesPlugin.builder().setGlobalPropertiesPluginData(globalPropertiesPluginData)
.getGlobalPropertiesPlugin();
}

private void execute() {
Expand Down Expand Up @@ -293,8 +283,9 @@ private void execute() {
continue;
}
if (pluginData instanceof PersonPropertiesPluginData) {
personPropertiesPlugin = PersonPropertiesPlugin
.getPersonPropertyPlugin((PersonPropertiesPluginData) pluginData);
personPropertiesPlugin = PersonPropertiesPlugin.builder()
.setPersonPropertiesPluginData((PersonPropertiesPluginData) pluginData)
.getPersonPropertyPlugin();
continue;
}

Expand All @@ -304,8 +295,9 @@ private void execute() {
}

if (pluginData instanceof GlobalPropertiesPluginData) {
globalPropertiesPlugin = GlobalPropertiesPlugin
.getGlobalPropertiesPlugin((GlobalPropertiesPluginData) pluginData);
globalPropertiesPlugin = GlobalPropertiesPlugin.builder()
.setGlobalPropertiesPluginData((GlobalPropertiesPluginData) pluginData)
.getGlobalPropertiesPlugin();
continue;
}

Expand Down Expand Up @@ -402,8 +394,6 @@ private void handleExperiementOpen(ExperimentContext experimentContext) {
.addTranslatorSpec(new RegionTranslatorSpec());

this.writingTranslatorController = translatorControllerBuilder.build();

this.writingTranslatorController.init();
}

private void handleSimulationStateCollection(Integer scenarioId, List<Object> output) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,24 @@
package lesson.translatorSpecs;

import com.google.protobuf.Descriptors.EnumDescriptor;
import com.google.protobuf.ProtocolMessageEnum;

import gov.hhs.aspr.gcm.translation.core.AEnumTranslatorSpec;
import gov.hhs.aspr.gcm.translation.protobuf.core.AbstractTranslatorSpec;
import lesson.input.GlobalPropertyInput;
import lesson.plugins.model.GlobalProperty;

public class GlobalPropertyTranslatorSpec extends AEnumTranslatorSpec<GlobalPropertyInput, GlobalProperty> {
public class GlobalPropertyTranslatorSpec extends AbstractTranslatorSpec<GlobalPropertyInput, GlobalProperty> {

@Override
protected GlobalProperty convertInputObject(GlobalPropertyInput inputObject) {
return GlobalProperty.valueOf(inputObject.name());
}

@Override
protected GlobalPropertyInput convertSimObject(GlobalProperty simObject) {
protected GlobalPropertyInput convertAppObject(GlobalProperty simObject) {
return GlobalPropertyInput.valueOf(simObject.name());
}

@Override
public EnumDescriptor getDescriptorForInputObject() {
return GlobalPropertyInput.getDescriptor();
}

@Override
public EnumInstance getEnumInstance() {
return new EnumInstance() {

@Override
public ProtocolMessageEnum getFromString(String arg0) {
return GlobalPropertyInput.valueOf(arg0);
}

};
public GlobalPropertyInput getDefaultInstanceForInputObject() {
return GlobalPropertyInput.forNumber(0);
}

@Override
Expand All @@ -42,7 +27,7 @@ public Class<GlobalPropertyInput> getInputObjectClass() {
}

@Override
public Class<GlobalProperty> getSimObjectClass() {
public Class<GlobalProperty> getAppObjectClass() {
return GlobalProperty.class;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,24 @@
package lesson.translatorSpecs;

import com.google.protobuf.Descriptors.EnumDescriptor;
import com.google.protobuf.ProtocolMessageEnum;

import gov.hhs.aspr.gcm.translation.core.AEnumTranslatorSpec;
import gov.hhs.aspr.gcm.translation.protobuf.core.AbstractTranslatorSpec;
import lesson.input.PersonPropertyInput;
import lesson.plugins.model.PersonProperty;

public class PersonPropertyTranslatorSpec extends AEnumTranslatorSpec<PersonPropertyInput, PersonProperty> {
public class PersonPropertyTranslatorSpec extends AbstractTranslatorSpec<PersonPropertyInput, PersonProperty> {

@Override
protected PersonProperty convertInputObject(PersonPropertyInput inputObject) {
return PersonProperty.valueOf(inputObject.name());
}

@Override
protected PersonPropertyInput convertSimObject(PersonProperty simObject) {
protected PersonPropertyInput convertAppObject(PersonProperty simObject) {
return PersonPropertyInput.valueOf(simObject.name());
}

@Override
public EnumDescriptor getDescriptorForInputObject() {
return PersonPropertyInput.getDescriptor();
}

@Override
public EnumInstance getEnumInstance() {
return new EnumInstance() {

@Override
public ProtocolMessageEnum getFromString(String arg0) {
return PersonPropertyInput.valueOf(arg0);
}

};
public PersonPropertyInput getDefaultInstanceForInputObject() {
return PersonPropertyInput.forNumber(0);
}

@Override
Expand All @@ -42,9 +27,8 @@ public Class<PersonPropertyInput> getInputObjectClass() {
}

@Override
public Class<PersonProperty> getSimObjectClass() {
return
PersonProperty.class;
public Class<PersonProperty> getAppObjectClass() {
return PersonProperty.class;
}

}
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package lesson.translatorSpecs;

import com.google.protobuf.Descriptors.Descriptor;

import gov.hhs.aspr.gcm.translation.core.AObjectTranslatorSpec;
import gov.hhs.aspr.gcm.translation.protobuf.core.AbstractTranslatorSpec;
import lesson.input.RegionInput;
import lesson.plugins.model.Region;

public class RegionTranslatorSpec extends AObjectTranslatorSpec<RegionInput, Region> {
public class RegionTranslatorSpec extends AbstractTranslatorSpec<RegionInput, Region> {

@Override
protected Region convertInputObject(RegionInput inputObject) {
return new Region(inputObject.getId());
return new Region(inputObject.getId());
}

@Override
protected RegionInput convertSimObject(Region simObject) {
protected RegionInput convertAppObject(Region simObject) {
return RegionInput.newBuilder().setId(simObject.getValue()).build();
}

Expand All @@ -23,21 +21,14 @@ public RegionInput getDefaultInstanceForInputObject() {
return RegionInput.getDefaultInstance();
}

@Override
public Descriptor getDescriptorForInputObject() {
return RegionInput.getDescriptor();
}

@Override
public Class<RegionInput> getInputObjectClass() {
return RegionInput.class;
}

@Override
public Class<Region> getSimObjectClass() {
public Class<Region> getAppObjectClass() {
return Region.class;
}



}
2 changes: 1 addition & 1 deletion demos/demo1/src/main/proto/lesson.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package gov.hhs.aspr.gcm;
package gov.hhs.aspr.gcm.translation.demo;

option java_multiple_files = true;
option java_package = "lesson.input";
Expand Down
Loading