Skip to content

Commit

Permalink
No Longer Use Class Globals When Exporting
Browse files Browse the repository at this point in the history
  • Loading branch information
AvocadoMoon committed Oct 1, 2024
1 parent e090ed3 commit 8f9e212
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docker/swarm/README_zeke_stack_on_linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
2.
```bash
pushd ../build
./build.sh --skip-maven --skip-singularity --skip-sudo all localhost:5000/virtualcell dev_zeke
./build.sh --skip-maven --skip-sudo all localhost:5000/virtualcell dev_zeke
popd
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ public class ExportServiceImpl implements ExportConstants, ExportService {

private Hashtable<Long, User> jobRequestIDs = new Hashtable<Long, User>();
private Hashtable<ExportSpecs, JobRequest> completedExportRequests = new Hashtable<ExportSpecs, JobRequest>();

private ASCIIExporter asciiExporter = new ASCIIExporter(this);
private IMGExporter imgExporter = new IMGExporter(this);
private RasterExporter rrExporter = new RasterExporter(this);

private N5Exporter n5Exporter = new N5Exporter(this);


/**
Expand Down Expand Up @@ -268,6 +262,10 @@ public ExportEvent makeRemoteFile(OutputContext outputContext,User user, DataSer
FileDataContainerManager fileDataContainerManager = new FileDataContainerManager();
try{
ExportOutput[] exportOutputs = null;
RasterExporter rrExporter = new RasterExporter(this);
IMGExporter imgExporter = new IMGExporter(this);
ASCIIExporter asciiExporter = new ASCIIExporter(this);

switch (exportSpecs.getFormat()) {
case CSV:
case HDF5:
Expand Down Expand Up @@ -313,9 +311,9 @@ public ExportEvent makeRemoteFile(OutputContext outputContext,User user, DataSer
exportOutputs = rrExporter.makeVTKUnstructuredData(outputContext,newExportJob, user, dataServerImpl, exportSpecs,fileDataContainerManager);
return saveResultsToRemoteFile(fileFormat, exportBaseDir, exportBaseURL, exportOutputs, exportSpecs, newExportJob,fileDataContainerManager);
case N5:
n5Exporter.initalizeDataControllers(user, dataServerImpl, (VCSimulationDataIdentifier) exportSpecs.getVCDataIdentifier());
N5Exporter n5Exporter = new N5Exporter(this, user, dataServerImpl, (VCSimulationDataIdentifier) exportSpecs.getVCDataIdentifier());
ExportOutput exportOutput = n5Exporter.makeN5Data(outputContext, newExportJob, exportSpecs, fileDataContainerManager);
return makeRemoteN5File(fileFormat, n5Exporter.getN5FileNameHash(), exportOutput, exportSpecs, newExportJob);
return makeRemoteN5File(fileFormat, n5Exporter.getN5FileNameHash(), exportOutput, exportSpecs, newExportJob, n5Exporter.getN5FilePathSuffix());
default:
throw new DataAccessException("Unknown export format requested");
}
Expand Down Expand Up @@ -475,11 +473,11 @@ private ExportEvent makeRemoteFile_Unzipped(String fileFormat, String exportBase
}


private ExportEvent makeRemoteN5File(String fileFormat, String fileName, ExportOutput exportOutput, ExportSpecs exportSpecs, JobRequest newExportJob) throws DataFormatException, IOException{
private ExportEvent makeRemoteN5File(String fileFormat, String fileName, ExportOutput exportOutput, ExportSpecs exportSpecs, JobRequest newExportJob, String pathSuffix) throws DataFormatException, IOException{
if (exportOutput.isValid()) {
completedExportRequests.put(exportSpecs, newExportJob);
String url = PropertyLoader.getRequiredProperty(PropertyLoader.s3ExportBaseURLProperty);
url += "/" + n5Exporter.getN5FilePathSuffix();
url += "/" + pathSuffix;
N5Specs n5Specs = (N5Specs) exportSpecs.getFormatSpecificSpecs();
url += "?dataSetName=" + newExportJob.getExportJobID();
if (lg.isTraceEnabled()) lg.trace("ExportServiceImpl.makeRemoteFile(): Successfully exported to file: " + fileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public class N5Exporter implements ExportConstants {
));


public N5Exporter(ExportServiceImpl exportServiceImpl) {
this.exportServiceImpl = exportServiceImpl;
}
public N5Exporter(ExportServiceImpl exportServiceImpl, User user, DataServerImpl dataServer, VCSimulationDataIdentifier vcSimulationDataIdentifier) {
this.exportServiceImpl = exportServiceImpl;
}

private ExportOutput exportToN5(OutputContext outputContext, long jobID, N5Specs n5Specs, ExportSpecs exportSpecs, FileDataContainerManager fileDataContainerManager) throws Exception {
VCUnitDefinition lengthUnit = ModelUnitSystem.createDefaultVCModelUnitSystem().getLengthUnit();
Expand Down Expand Up @@ -139,10 +139,12 @@ private ExportOutput exportToN5(OutputContext outputContext, long jobID, N5Specs

int timeLoops = 1;
double progress = 0;

for (int variableIndex=0; variableIndex < (numVariables -1); variableIndex++){
for (int timeIndex=timeSpecs.getBeginTimeIndex(); timeIndex <= timeSpecs.getEndTimeIndex(); timeIndex++){
int normalizedTimeIndex = timeIndex - timeSpecs.getBeginTimeIndex();

System.out.print("Writing with VCid: " + vcDataID + ".");
double[] data = this.dataServer.getSimDataBlock(outputContext, user, this.vcDataID, variableNames[variableIndex], allTimes[timeIndex]).getData();
data = containsPostProcessed ? data : MeshToImage.convertMeshIntoImage(data, mesh).data();
for (int z=0; z < sizeZ; z++){
Expand Down Expand Up @@ -195,12 +197,6 @@ private boolean containsPostProcessedVariable(String[] variableNames, OutputCont
return false;
}

public void initalizeDataControllers(User user, DataServerImpl dataServer, VCSimulationDataIdentifier vcSimulationDataIdentifier) throws IOException, DataAccessException {
this.user = user;
this.vcDataID = vcSimulationDataIdentifier;
this.dataServer = dataServer;
}


public VCSimulationDataIdentifier getVcDataID(){return vcDataID;}

Expand Down

0 comments on commit 8f9e212

Please sign in to comment.