Skip to content

Commit

Permalink
Trying different import
Browse files Browse the repository at this point in the history
  • Loading branch information
Hjorthmedh committed Dec 5, 2024
1 parent fe56edd commit dd1a298
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions snudda/detect/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2613,28 +2613,26 @@ def setup_parallel(self, d_view=None):

self.write_log(f"setup_parallel: {d_view = }")

try:
with d_view.sync_imports():
from snudda.detect.detect import SnuddaDetect

except Exception as e:
self.write_log("Error during sync_imports:")
self.write_log(str(e))
# with d_view.sync_imports():
# from snudda.detect.detect import SnuddaDetect

cmd_errorstr = """
import os
import traceback
import uuid
import traceback
tstr = traceback.format_exc()
tmp = open(os.path.join(f"worker-error-file-{uuid.uuid4()}"), 'w')
tmp.write(f"Exception: {tstr}")
tmp.close()
import_cmd = """
try:
from snudda.detect.detect import SnuddaDetect
except Exception as e:
import os
import traceback
import uuid
import traceback
tstr = traceback.format_exc()
tmp = open(os.path.join(f"worker-error-file-{uuid.uuid4()}"), 'w')
tmp.write(f"Exception: {e}\n")
tmp.write(f"Exception: {tstr}\n")
tmp.close()
raise
"""
d_view.execute(cmd_errorstr, block=True)

raise # Re-raise the exception to stop the job
d_view.execute(import_cmd, block=True)

self.write_log(f"Setting up workers: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())}")

Expand Down

0 comments on commit dd1a298

Please sign in to comment.