Skip to content

Commit df2dfa1

Browse files
authored
Merge pull request #14 from xsuite/release/v0.1.5
Release 0.1.5
2 parents a0c52c8 + f7a2357 commit df2dfa1

27 files changed

+204
-83
lines changed

examples/running/lossmap.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@
2727

2828

2929
# Run xboinc
30-
cmd = subprocess.run(['uname', '-ms'], stdout=subprocess.PIPE)
31-
architecture = cmd.stdout.decode('UTF-8').strip().lower().replace(' ','-')
32-
exec_file = list(Path.cwd().glob(f'xboinc_{xb.app_version}-{architecture}'))
33-
if len(exec_file)==0 or not exec_file[0].exists():
30+
cmd = subprocess.run(['uname', '-m'], stdout=subprocess.PIPE)
31+
arch = cmd.stdout.decode('UTF-8').strip().lower()
32+
cmd = subprocess.run(['uname', '-s'], stdout=subprocess.PIPE)
33+
thisos = cmd.stdout.decode('UTF-8').strip().lower()
34+
exec_files = list(Path.cwd().glob(f'xboinc_{xb.app_version}-*'))
35+
exec_files = [f for f in exec_files if arch in str(f) and thisos in str(f)]
36+
if len(exec_files)==0 or not exec_files[0].exists():
3437
raise ValueError("No executable found")
35-
exec_file = exec_file[0]
38+
exec_file = exec_files[0]
3639
cmd = subprocess.run(exec_file)
3740
if cmd.returncode != 0:
3841
raise RuntimeError(f"Tracking failed.")

examples/running/simple_line.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# copyright ############################### #
2+
# This file is part of the Xboinc Package. #
3+
# Copyright (c) CERN, 2023. #
4+
########################################### #
5+
16
import subprocess
27
from pathlib import Path
38
import numpy as np
@@ -17,12 +22,15 @@
1722

1823

1924
# Run xboinc
20-
cmd = subprocess.run(['uname', '-ms'], stdout=subprocess.PIPE)
21-
architecture = cmd.stdout.decode('UTF-8').strip().lower().replace(' ','-')
22-
exec_file = list(Path.cwd().glob(f'xboinc_{xb.app_version}-{architecture}'))
23-
if len(exec_file)==0 or not exec_file[0].exists():
25+
cmd = subprocess.run(['uname', '-m'], stdout=subprocess.PIPE)
26+
arch = cmd.stdout.decode('UTF-8').strip().lower()
27+
cmd = subprocess.run(['uname', '-s'], stdout=subprocess.PIPE)
28+
thisos = cmd.stdout.decode('UTF-8').strip().lower()
29+
exec_files = list(Path.cwd().glob(f'xboinc_{xb.app_version}-*'))
30+
exec_files = [f for f in exec_files if arch in str(f) and thisos in str(f)]
31+
if len(exec_files)==0 or not exec_files[0].exists():
2432
raise ValueError("No executable found")
25-
exec_file = exec_file[0]
33+
exec_file = exec_files[0]
2634
cmd = subprocess.run(exec_file)
2735
if cmd.returncode != 0:
2836
raise RuntimeError(f"Tracking failed.")
278 KB
Binary file not shown.
-278 KB
Binary file not shown.
-287 KB
Binary file not shown.
344 KB
Binary file not shown.
384 KB
Binary file not shown.
302 KB
Binary file not shown.

examples/submission.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,23 @@
2323

2424
studyname = "example_study"
2525

26-
with xb.SubmitJobs(user=user, study=studyname) as job:
26+
27+
# Submission can be done in a context, where the submission
28+
# itself is triggered when exiting the context
29+
with xb.SubmitJobs(user=user, study=studyname) as submitter:
2730
for i in range(int(num_particles/particles_per_sub)):
2831
particles = xp.Particles(x=np.random.normal(0, 0.0001, particles_per_sub),
2932
y=np.random.normal(0, 0.0001, particles_per_sub))
30-
job.add(job_name=f'{studyname}_{i}', num_turns=num_turns, line=line, particles=particles,
33+
submitter.add(job_name=f'{studyname}_{i}', num_turns=num_turns, line=line, particles=particles,
3134
checkpoint_every=100)
3235

36+
37+
# Or by manually triggering the submission
38+
submitter = xb.SubmitJobs(user=user, study=studyname)
39+
for i in range(int(num_particles/particles_per_sub)):
40+
particles = xp.Particles(x=np.random.normal(0, 0.0001, particles_per_sub),
41+
y=np.random.normal(0, 0.0001, particles_per_sub))
42+
submitter.add(job_name=f'{studyname}_{i}', num_turns=num_turns, line=line, particles=particles,
43+
checkpoint_every=100)
44+
submitter.submit()
45+

0 commit comments

Comments
 (0)