Skip to content

Commit

Permalink
Merge pull request #9995 from gem/oq-reset
Browse files Browse the repository at this point in the history
Extended `oq reset` to also remove the `custom_tmp` directory, if any
  • Loading branch information
micheles authored Sep 30, 2024
2 parents 80e7267 + 580bb56 commit d8814d3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[Michele Simionato]
* Extended `oq reset` to also remove the `custom_tmp` directory, if any
* Added classes CampbellBozorgnia2019, CampbellBozorgnia2019HighQ, CampbellBozorgnia2019LowQ
* Reduced the size of the large CSV files in hazardlib and added a check
to forbid files larger than 600k
Expand Down
2 changes: 1 addition & 1 deletion openquake/baselib/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def scratch_dir(job_id):
tmp = config.directory.custom_tmp or tempfile.gettempdir()
dirname = os.path.join(tmp, f'calc_{job_id}')
try:
os.mkdir(dirname)
os.makedirs(dirname)
except FileExistsError: # already created
pass
return dirname
Expand Down
6 changes: 6 additions & 0 deletions openquake/commands/purge.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
# along with OpenQuake. If not, see <http://www.gnu.org/licenses/>.
import os
import re
import shutil
import getpass
from openquake.baselib import config
from openquake.baselib.general import humansize
from openquake.commonlib import logs, datastore

Expand Down Expand Up @@ -51,6 +53,10 @@ def purge_all(user=None):
if mo is not None:
calc_id = int(mo.group(1))
purge_one(calc_id, user, force=True)
custom_tmp = config.directory.custom_tmp
if custom_tmp and os.path.exists(custom_tmp):
shutil.rmtree(custom_tmp)
print(f'Removed {custom_tmp}')


def purge(status, days, force):
Expand Down

0 comments on commit d8814d3

Please sign in to comment.