sxs 2024.0.33__py3-none-any.whl → 2024.0.35__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sxs/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2024.0.33"
1
+ __version__ = "2024.0.35"
sxs/simulations/local.py CHANGED
@@ -65,7 +65,7 @@ def extract_id_from_common_metadata(file, annex_dir):
65
65
  return key
66
66
 
67
67
 
68
- def local_simulations(annex_dir, compute_md5=False):
68
+ def local_simulations(annex_dir, compute_md5=False, show_progress=False):
69
69
  """
70
70
  Walk the annex directory to find and process all simulations
71
71
 
@@ -91,6 +91,8 @@ def local_simulations(annex_dir, compute_md5=False):
91
91
  compute_md5 : bool, optional
92
92
  Whether to compute the MD5 hash of each file. Default is
93
93
  False.
94
+ show_progress : bool, optional
95
+ Whether to show a progress bar. Default is False.
94
96
 
95
97
  Returns
96
98
  -------
@@ -99,10 +101,24 @@ def local_simulations(annex_dir, compute_md5=False):
99
101
  """
100
102
  from os import walk
101
103
  from ..utilities import md5checksum
104
+ from tqdm import tqdm
102
105
 
103
106
  simulations = {}
104
107
  annex_dir = Path(annex_dir).resolve()
105
108
 
109
+ if show_progress: # Count the number of common-metadata.txt files
110
+ num_files = 0
111
+ for dirpath, dirnames, filenames in walk(annex_dir, topdown=True):
112
+ if Path(dirpath).name.startswith("."):
113
+ dirnames[:] = []
114
+ continue
115
+ if "common-metadata.txt" in filenames:
116
+ if not any(d.startswith("Lev") for d in dirnames):
117
+ continue
118
+ num_files += 1
119
+ dirnames[:] = []
120
+ progress_bar = tqdm(total=num_files, desc="Processing simulations")
121
+
106
122
  # The `walk` method can be made *much* faster than the `glob` method
107
123
  for dirpath, dirnames, filenames in walk(annex_dir, topdown=True):
108
124
  dirpath = Path(dirpath)
@@ -116,40 +132,47 @@ def local_simulations(annex_dir, compute_md5=False):
116
132
  if not any(d.startswith("Lev") for d in dirnames):
117
133
  continue
118
134
 
119
- key = extract_id_from_common_metadata(dirpath / "common-metadata.txt", annex_dir)
135
+ if show_progress:
136
+ progress_bar.update(1)
120
137
 
121
- # Find the highest Lev directory and extract the metadata
122
- highest_lev = sorted(
123
- [d for d in dirnames if d.startswith("Lev")]
124
- )[-1]
125
- metadata = Metadata.load(dirpath / highest_lev / "metadata")
126
- metadata = metadata.add_standard_parameters()
138
+ try:
139
+ key = extract_id_from_common_metadata(dirpath / "common-metadata.txt", annex_dir)
127
140
 
128
- metadata["directory"] = str(dirpath.relative_to(annex_dir))
141
+ # Find the highest Lev directory and extract the metadata
142
+ highest_lev = sorted(
143
+ [d for d in dirnames if d.startswith("Lev")]
144
+ )[-1]
145
+ metadata = Metadata.load(dirpath / highest_lev / "metadata")
146
+ metadata = metadata.add_standard_parameters()
129
147
 
130
- metadata["files"] = {
131
- path_to_invenio(file.relative_to(dirpath)): {
132
- "link": str(file),
133
- "size": file.stat().st_size,
134
- "checksum": md5checksum(file) if compute_md5 else "",
148
+ metadata["directory"] = str(dirpath.relative_to(annex_dir))
149
+
150
+ metadata["files"] = {
151
+ path_to_invenio(file.relative_to(dirpath)): {
152
+ "link": str(file),
153
+ "size": file.stat().st_size,
154
+ "checksum": md5checksum(file) if compute_md5 else "",
155
+ }
156
+ for file in files_to_upload(dirpath, annex_dir)
135
157
  }
136
- for file in files_to_upload(dirpath, annex_dir)
137
- }
138
158
 
139
- simulations[key] = metadata
159
+ simulations[key] = metadata
160
+ except KeyboardInterrupt:
161
+ raise
162
+ except Exception as e:
163
+ print(f"Error processing {dirpath}: {e}")
140
164
 
141
165
  dirnames[:] = [] # Don't keep looking for common-metadata.txt files under this directory
142
166
 
143
167
  return simulations
144
168
 
145
169
 
146
- def write_local_simulations(annex_dir, output_file=None):
170
+ def write_local_simulations(annex_dir, output_file=None, compute_md5=False, show_progress=False):
147
171
  """Write the local simulations to a file for use when loading `Simulations`
148
172
 
149
173
  This function calls `local_simulations` to obtain the dictionary,
150
174
  but also writes the dictionary to a JSON file.
151
175
 
152
-
153
176
  Parameters
154
177
  ----------
155
178
  annex_dir : (str or Path)
@@ -159,6 +182,11 @@ def write_local_simulations(annex_dir, output_file=None):
159
182
  written to `sxs_directory("cache") / "local_simulations.json"`.
160
183
  N.B.: If you specify a different file, `sxs.load` will not
161
184
  automatically find it.
185
+ compute_md5 : bool, optional
186
+ Whether to compute the MD5 hash of each file. Default is
187
+ False.
188
+ show_progress : bool, optional
189
+ Whether to show a progress bar. Default is False.
162
190
 
163
191
  Returns
164
192
  -------
@@ -168,7 +196,7 @@ def write_local_simulations(annex_dir, output_file=None):
168
196
  from json import dump
169
197
 
170
198
  # Process the annex directory to find all simulations
171
- simulations = local_simulations(annex_dir)
199
+ simulations = local_simulations(annex_dir, compute_md5=compute_md5, show_progress=show_progress)
172
200
 
173
201
  # Write the simulations to file
174
202
  if output_file is None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sxs
3
- Version: 2024.0.33
3
+ Version: 2024.0.35
4
4
  Summary: Interface to data produced by the Simulating eXtreme Spacetimes collaboration
5
5
  Project-URL: Homepage, https://github.com/sxs-collaboration/sxs
6
6
  Project-URL: Documentation, https://sxs.readthedocs.io/
@@ -1,5 +1,5 @@
1
1
  sxs/__init__.py,sha256=hbydsXWR88sFiKExPJ1NHWGEvWRbbJBjSc1irSMYKgY,2623
2
- sxs/__version__.py,sha256=1aAfFJkJXDhyQxvB5A7JGzfK5gLev3uJrAgjXgoxXkA,26
2
+ sxs/__version__.py,sha256=EllLyvaqy_ewNHGD4IRCW0Koomey3HParQ9NwzwM1EE,26
3
3
  sxs/handlers.py,sha256=Nc1_aDKm_wDHg2cITI_ljbqU4VRWpwQ7fdgy3c1XcE8,17531
4
4
  sxs/juliapkg.json,sha256=-baaa3Za_KBmmiGjlh2YYLWmvUvZl6GaKKXwNI4S7qU,178
5
5
  sxs/time_series.py,sha256=OKaLg8tFyrtKcef7900ri-a0C6A8wKxA68KovZXvH6I,41081
@@ -18,7 +18,7 @@ sxs/julia/__init__.py,sha256=uSLP_xfU-GZG7IO5vs0TEkCR4LH8aBYMF-852wDY3kI,3490
18
18
  sxs/metadata/__init__.py,sha256=KCvJ9Cf1WhIZp-z28UzarKcmUAzV2BOv2gqKiorILjo,149
19
19
  sxs/metadata/metadata.py,sha256=EEax1WTKL4G5U__wHefbBX0l4vtIHTcYFnHwziGkVhM,28348
20
20
  sxs/simulations/__init__.py,sha256=GrZym0PHTULDg_hyFmISNzDfqVLz_hQo-djbgecZs54,134
21
- sxs/simulations/local.py,sha256=51ULBmrodAPZXv2_qpLeEWKIR9zwPGR-zPt7XG8Vcqs,6403
21
+ sxs/simulations/local.py,sha256=gIkKtmSBVK_jGVYdGK_axby0USU992U5gAXugiUPJUk,7718
22
22
  sxs/simulations/simulation.py,sha256=OqQh6xq-s_JoQI6e2XA5j194L0DT3HGYIW8ZZiurZ2Y,34631
23
23
  sxs/simulations/simulations.py,sha256=ATxrcihvblGgRHdR7vIMg5eKghN5Jo6U0CafTro4wYA,24827
24
24
  sxs/utilities/__init__.py,sha256=WSStlqljfgQheMxHGfuofSc5LdmASGvO3FNO3f_zaT0,4806
@@ -80,7 +80,7 @@ sxs/zenodo/api/__init__.py,sha256=EM_eh4Q8R5E0vIfMhyIR1IYFfOBu6vA0UTasgX9gHys,21
80
80
  sxs/zenodo/api/deposit.py,sha256=J4RGvGjh0cEOrN4bBZWEDcPAhNscqB2fzLlvRZ5HTHM,36948
81
81
  sxs/zenodo/api/login.py,sha256=Yz0ytgi81_5BpDzhrS0WPMXlvU2qUaCK8yn8zxfEbko,18007
82
82
  sxs/zenodo/api/records.py,sha256=nKkhoHZ95CTztHF9Zzaug5p7IiUCJG4Em1i-l-WqH6U,3689
83
- sxs-2024.0.33.dist-info/METADATA,sha256=agwAnGwVuDDEI52_MS-8kMT1aX7c6Ps-E5SWq0l6kYE,9253
84
- sxs-2024.0.33.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
85
- sxs-2024.0.33.dist-info/licenses/LICENSE,sha256=ptVOd5m7LDM5ZF0x32cxb8c2Nd5NDmAhy6DX7xt_7VA,1080
86
- sxs-2024.0.33.dist-info/RECORD,,
83
+ sxs-2024.0.35.dist-info/METADATA,sha256=pNDJsKKS1zTnp0m_dAWi7fVxi6QRKFqGKu96TPpDdJ0,9253
84
+ sxs-2024.0.35.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
85
+ sxs-2024.0.35.dist-info/licenses/LICENSE,sha256=ptVOd5m7LDM5ZF0x32cxb8c2Nd5NDmAhy6DX7xt_7VA,1080
86
+ sxs-2024.0.35.dist-info/RECORD,,