Skip to content

Commit ee9c8a9

Browse files
aqjune-awsstrata-bot
authored andcommitted
Enable --keep-all-files in other strata commands
1 parent 3a57c46 commit ee9c8a9

5 files changed

Lines changed: 11 additions & 13 deletions

File tree

‎StrataPython/Cli.lean‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,6 @@ def pyAnalyzeLaurelCommand (mkDischarge : Core.MkDischargeFn := Core.mkDischarge
239239
{ name := "pyspec",
240240
help := "PySpec module name (e.g., servicelib.Storage).",
241241
takesArg := .repeat "module" },
242-
{ name := "keep-all-files",
243-
help := "Store intermediate Laurel and Core programs in <dir>.",
244-
takesArg := .arg "dir" },
245242
{ name := "entry-point",
246243
help := "Which procedures to verify: main (main fn only), roots (user procs with no user callers, default), or all (all user procs). Only valid in bugFinding mode.",
247244
takesArg := .arg "mode" },
@@ -278,13 +275,12 @@ def pyAnalyzeLaurelCommand (mkDischarge : Core.MkDischargeFn := Core.mkDischarge
278275
| some path => some <$> IO.FS.Handle.mk path .write
279276
| none => pure none
280277

281-
let keepPrefix := keepDir.map (s!"{·}/{baseName}")
282278
let baseVcDir := keepDir.map (fun dir => (s!"{dir}/{baseName}" : System.FilePath))
283279
let pyAnalyzeBase : VerifyOptions :=
284280
{ VerifyOptions.default with
285281
verbose := .quiet, removeIrrelevantAxioms := .Precise,
286282
vcDirectory := baseVcDir }
287-
let options ← parseVerifyOptions pflags pyAnalyzeBase
283+
let options ← parseVerifyOptions pflags pyAnalyzeBase (inputFile := some filePath)
288284
let isBugFinding := options.checkMode == .bugFinding
289285
|| options.checkMode == .bugFindingAssumingCompleteSpec
290286

@@ -313,7 +309,6 @@ def pyAnalyzeLaurelCommand (mkDischarge : Core.MkDischargeFn := Core.mkDischarge
313309
let (outcome, laurelPassStats, pctx) ← StrataPython.Pipeline.runPyAnalyzePipeline {
314310
filePath, specDir
315311
dispatchModules, pyspecModules, sourcePath
316-
keepAllFilesPrefix := keepPrefix
317312
verifyOptions := options
318313
entryPoint, isBugFinding
319314
outputMode, skipVerification
@@ -555,12 +550,18 @@ def pyResolveOverloadsCommand : _root_.Command where
555550
def pyInterpretCommand : _root_.Command where
556551
name := "pyInterpret"
557552
args := [ "file" ]
558-
flags := [{ name := "fuel", help := "Maximum execution steps.", takesArg := .arg "n" }]
559-
++ laurelTranslateFlags
553+
flags := [{ name := "fuel", help := "Maximum execution steps.", takesArg := .arg "n" },
554+
{ name := "keep-all-files",
555+
help := "Store intermediate Laurel and Core programs in <dir>.",
556+
takesArg := .arg "dir" }]
560557
help := "Interpret a Python Ion program concretely (Python → Laurel → Core → execute)."
561558
callback := fun v pflags => do
562559
let filePath := v[0]
563560
let keepDir := pflags.getString "keep-all-files"
561+
-- Derive a prefix *inside* the directory so pipeline-emitted intermediates
562+
-- (`<dir>/<baseName>.<n>.<pass>.laurel.st`) land alongside the final
563+
-- programs instead of as siblings of the directory.
564+
let keepPrefix := keepDir.map (s!"{·}/{deriveBaseName filePath}")
564565
let fuel ← match pflags.getString "fuel" with
565566
| some s => match s.toNat? with
566567
| .some n => pure n
@@ -574,7 +575,7 @@ def pyInterpretCommand : _root_.Command where
574575
if let some dir := keepDir then
575576
IO.FS.createDirAll dir
576577
IO.FS.writeFile (dir ++ "/laurel.st") (toString (Std.format laurel))
577-
match ← StrataPython.translateCombinedLaurel laurel keepDir
578+
match ← StrataPython.translateCombinedLaurel laurel keepPrefix
578579
(analysisMode := .Execute) with
579580
| (some core, diags) => pure (core, diags)
580581
| (none, diags) => exitFailure s!"Laurel to Core translation failed: {diags}"

‎StrataPython/Pipeline/PyAnalyzeLaurel.lean‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public structure PyAnalyzeConfig where
3333
dispatchModules : Array String := #[]
3434
pyspecModules : Array String := #[]
3535
sourcePath : Option String := none
36-
keepAllFilesPrefix : Option String := none
3736
verifyOptions : Core.VerifyOptions
3837
entryPoint : Core.EntryPoint := Core.EntryPoint.roots
3938
isBugFinding : Bool := true
@@ -62,7 +61,7 @@ private def runPipeline (config : PyAnalyzeConfig)
6261
let ctx ← read
6362
let laurelResult ←
6463
StrataPython.translateCombinedLaurelWithLowered combinedLaurel
65-
(keepAllFilesPrefix := config.keepAllFilesPrefix)
64+
(keepAllFilesPrefix := config.verifyOptions.keepAllFilesPrefix)
6665
(pipelineCtx := some ctx) |>.toBaseIO
6766
match laurelResult with
6867
| .ok (coreOpt, diags, _, stats) =>
@@ -101,7 +100,6 @@ private def runPipeline (config : PyAnalyzeConfig)
101100
(proceduresToVerify := some proceduresToVerify)
102101
(externalPhases := [Strata.frontEndPhase])
103102
(prefixPhases := inlinePhases)
104-
(keepAllFilesPrefix := config.keepAllFilesPrefix)
105103
(mkDischarge := config.mkDischarge)
106104
(pipelineCtx := some ctx)
107105
|>.toBaseIO

‎Tools/Python-base/.gitignore‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)