Skip to content

Commit

Permalink
Save slot list before checking if it satisfies epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
gagliardetto committed Sep 25, 2023
1 parent 50dab78 commit db32960
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions cmd/radiance/car/createcar/cmd-create-car.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,22 @@ func run(c *cobra.Command, args []string) {
officialEpochStart,
officialEpochStop,
)

// write slots to a file {epoch}.slots.txt
slotsFilepath := filepath.Join(filepath.Dir(finalCARFilepath), fmt.Sprintf("%d.slots.txt", epoch))
klog.Infof("Saving slot list to file: %s", slotsFilepath)
slotsFile, err := os.Create(slotsFilepath)
if err != nil {
klog.Exitf("Failed to create slot list file: %s", err)
}
defer slotsFile.Close()
for _, slot := range slots {
_, err := slotsFile.WriteString(fmt.Sprintf("%d\n", slot))
if err != nil {
klog.Exitf("Failed to write slot to slots file: %s", err)
}
}

klog.Info("---")
if *flagRequireFullEpoch {
err := schedule.SatisfiesEpochEdges(epoch)
Expand Down Expand Up @@ -220,21 +236,6 @@ func run(c *cobra.Command, args []string) {
)
}

// write slots to a file {epoch}.slots.txt
slotsFilepath := filepath.Join(filepath.Dir(finalCARFilepath), fmt.Sprintf("%d.slots.txt", epoch))
klog.Infof("Saving slot list to file: %s", slotsFilepath)
slotsFile, err := os.Create(slotsFilepath)
if err != nil {
klog.Exitf("Failed to create slot list file: %s", err)
}
defer slotsFile.Close()
for _, slot := range slots {
_, err := slotsFile.WriteString(fmt.Sprintf("%d\n", slot))
if err != nil {
klog.Exitf("Failed to write slot to slots file: %s", err)
}
}

if *flagCheckOnly {
klog.Infof("Check only; exiting")
time.Sleep(1 * time.Second)
Expand Down

0 comments on commit db32960

Please sign in to comment.