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

Refactor/various fixes 2 #106

Merged
merged 5 commits into from
Aug 27, 2024
Merged
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
23 changes: 16 additions & 7 deletions cmd/commands/datasetIngestor.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ For Windows you need instead to specify -user username:password on the command l
return
}

// check for program version
// === check for program version ===
datasetUtils.CheckForNewVersion(client, CMD, VERSION)
datasetUtils.CheckForServiceAvailability(client, testenvFlag, autoarchiveFlag)

Expand Down Expand Up @@ -214,7 +214,9 @@ For Windows you need instead to specify -user username:password on the command l
}
color.Set(color.FgYellow)
if len(foundList) > 0 {
fmt.Println("Warning! The following datasets have been found with the same sourceFolder: ")
fmt.Println("Warning! The following datasets have been found with the same sourceFolders: ")
} else {
log.Println("Finished testing for existing source folders.")
}
for _, element := range foundList {
fmt.Printf(" - PID: \"%s\", sourceFolder: \"%s\"\n", element.Pid, element.SourceFolder)
Expand Down Expand Up @@ -277,15 +279,16 @@ For Windows you need instead to specify -user username:password on the command l
skipSymlinks = ""
}

// get filelist of dataset
// === get filelist of dataset ===
log.Printf("Getting filelist for \"%s\"...\n", datasetSourceFolder)
fullFileArray, startTime, endTime, owner, numFiles, totalSize, err :=
datasetIngestor.GetLocalFileList(datasetSourceFolder, datasetFileListTxt, localSymlinkCallback, localFilepathFilterCallback)
if err != nil {
log.Fatalf("Can't gather the filelist of \"%s\"", datasetSourceFolder)
}

log.Println("File list collected.")
//log.Printf("full fileListing: %v\n Start and end time: %s %s\n ", fullFileArray, startTime, endTime)
log.Printf("The dataset contains %v files with a total size of %v bytes.", numFiles, totalSize)
log.Printf("The dataset contains %v files with a total size of %v bytes.\n", numFiles, totalSize)

// filecount checks
if totalSize == 0 {
Expand All @@ -309,11 +312,13 @@ For Windows you need instead to specify -user username:password on the command l
log.Printf("Note: this dataset, if archived, will be copied to two tape copies")
color.Unset()
}
// === update metadata ===
datasetIngestor.UpdateMetaData(client, APIServer, user, originalMap, metaDataMap, startTime, endTime, owner, tapecopies)
pretty, _ := json.MarshalIndent(metaDataMap, "", " ")

log.Printf("Updated metadata object:\n%s\n", pretty)

// === check central availability of data ===
// check if data is accesible at archive server, unless beamline account (assumed to be centrally available always)
// and unless (no)copy flag defined via command line
if checkCentralAvailability {
Expand Down Expand Up @@ -348,6 +353,7 @@ For Windows you need instead to specify -user username:password on the command l
}
}

// === ingest dataset ===
if ingestFlag {
// create ingest . For decentral case delay setting status to archivable until data is copied
archivable := false
Expand Down Expand Up @@ -380,6 +386,7 @@ For Windows you need instead to specify -user username:password on the command l
}
log.Printf("Attachment file %v added to dataset %v\n", addAttachment, datasetId)
}
// === copying files ===
if copyFlag {
// TODO rewrite SyncDataToFileserver
log.Println("Syncing files to cache server...")
Expand All @@ -406,7 +413,8 @@ For Windows you need instead to specify -user username:password on the command l
archivableDatasetList = append(archivableDatasetList, datasetId)
}
}
datasetIngestor.ResetUpdatedMetaData(originalMap, metaDataMap) // I don't really get this...
// reset dataset metadata for next dataset ingestion
datasetIngestor.ResetUpdatedMetaData(originalMap, metaDataMap)
}

if !ingestFlag {
Expand Down Expand Up @@ -439,7 +447,8 @@ For Windows you need instead to specify -user username:password on the command l
if emptyDatasets > 0 || tooLargeDatasets > 0 {
os.Exit(1)
}
// start archive job

// === create archive job ===
if autoarchiveFlag && ingestFlag {
log.Printf("Submitting Archive Job for the ingested datasets.\n")
// TODO: change param type from pointer to regular as it is unnecessary
Expand Down
2 changes: 1 addition & 1 deletion datasetIngestor/ingestDataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func createOrigDatablocks(client *http.Client, APIServer string, fullFileArray [

if totalFiles > TOTAL_MAXFILES {
return fmt.Errorf(
"dataset exceeds (%v) the maximum number of files per dataset , which can currently be handled by the archiving system (%v)",
"dataset exceeds the maximum number of files that can be handled by the archiving system per dataset (dataset: %v, max: %v)",
totalFiles, TOTAL_MAXFILES)
}

Expand Down