Skip to content

Conversation

@ziotom78
Copy link
Member

@ziotom78 ziotom78 commented Jun 16, 2020

This PR adds the ability to append information about the status of the source code when calling Simulation.flush. It includes the following information:

  • Link to the source code repository (this one)
  • Latest commit hash, author, and message
  • If the code was changed after the last git commit command, provide the output of git diff
  • Date and time when the report was produced

The following is an example of a paragraph saved by the code in this PR


Source code used in the simulation

  • Main repository: github.com/litebird/litebird_sim
  • Version: 0.1.0, by The LiteBIRD simulation team
  • Commit hash: adc0da6
    (Add date and time to report, by Maurizio Tomasi)
    Since the last commit, the following changes have been made to the
    code that has been ran:
diff --git a/litebird_sim/simulations.py b/litebird_sim/simulations.py
index 5f2d58a..9702db1 100644
--- a/litebird_sim/simulations.py
+++ b/litebird_sim/simulations.py
@@ -118,13 +118,17 @@ class Simulation:
         # Retrieve information about the last git commit
         try:
             proc = subprocess.run(
-                ["git", "log", "-1", '--format=format:"%h%n%H%n%s%n%an"'],
+                ["git", "log", "-1", "--format=format:%h%n%H%n%s%n%an"],
                 capture_output=True,
+                encoding="utf-8",
             )
 
-            (short_commit_hash, commit_hash, commit_message, author) = (
-                proc.stdout.decode("utf-8").strip().split("\n")
-            )
+            (
+                short_commit_hash,
+                commit_hash,
+                commit_message,
+                author,
+            ) = proc.stdout.strip().split("\n")
 
             self.append_to_report(
                 """
@@ -141,7 +145,9 @@ class Simulation:
 
             # Retrieve information about changes in the code since the last commit
             proc = subprocess.run(
-                ["git", "diff", "--no-color", "--exit-code"], capture_output=True
+                ["git", "diff", "--no-color", "--exit-code"],
+                capture_output=True,
+                encoding="utf-8",
             )
 
             if proc.returncode != 0:
@@ -154,7 +160,7 @@ code that has been ran:

""".format(

  •                    proc.stdout.decode("utf-8").strip(),
    
  •                    proc.stdout.strip(),
                   )
               )
    
---

Report written on 2020-06-16 16:36:21

@ziotom78
Copy link
Member Author

Once Travis and Appveyor end their jobs, I'm ready to merge this. If you think that other information can be saved at the end of the report, please open an issue: I would like to merge this PR into PR#33, so that the report can contain a list of the IMO object using during the simulation as well.

@ziotom78 ziotom78 merged commit 7842d3d into master Jun 16, 2020
@ziotom78 ziotom78 deleted the code_status branch June 16, 2020 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant