yuclid 0.1.5__py3-none-any.whl → 0.1.7__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.
yuclid/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.5"
1
+ __version__ = "0.1.7"
yuclid/run.py CHANGED
@@ -13,6 +13,14 @@ def substitute_point_yvars(x, point_map, point_id):
13
13
  # replace ${yuclid.<name>} and ${yuclid.@} with point values
14
14
  value_pattern = r"\$\{yuclid\.([a-zA-Z0-9_]+)(?:\.value)?\}"
15
15
  name_pattern = r"\$\{yuclid\.([a-zA-Z0-9_]+)\.name\}"
16
+ matches = re.findall(name_pattern, x)
17
+ for name in matches:
18
+ if name not in point_map:
19
+ report(
20
+ LogLevel.FATAL,
21
+ f"point variable '{name}' not found in point_map",
22
+ hint=f"available variables: {', '.join(point_map.keys())}",
23
+ )
16
24
  y = re.sub(value_pattern, lambda m: str(point_map[m.group(1)]["value"]), x)
17
25
  y = re.sub(name_pattern, lambda m: str(point_map[m.group(1)]["name"]), y)
18
26
  if point_id is not None:
@@ -32,69 +40,56 @@ def substitute_global_yvars(x, subspace):
32
40
  return y
33
41
 
34
42
 
35
- def get_yvar_pattern():
36
- return r"\$\{yuclid\.([a-zA-Z0-9_@]+)\}"
43
+ def validate_point_yvars(space, exps):
44
+ for exp in exps:
45
+ matches = re.findall(
46
+ r"\$\{yuclid\.([a-zA-Z0-9_@]+)(?:\.(?:name|value|names|values))?\}", exp
47
+ )
48
+ for dim in matches:
49
+ if dim not in space and dim != "@":
50
+ report(LogLevel.FATAL, f"invalid variable 'yuclid.{dim}'", exp)
37
51
 
38
52
 
39
- def validate_yvars_in_env(env):
40
- for key, value in env.items():
41
- if re.search(get_yvar_pattern(), value):
53
+ def validate_global_yvars(space, exps):
54
+ for exp in exps:
55
+ exp = str(exp)
56
+ point_matches = re.findall(
57
+ r"\$\{yuclid\.([a-zA-Z0-9_@]+)(?:\.(?:name|value))?\}", exp
58
+ )
59
+ for dim in point_matches:
42
60
  hint = (
43
61
  "maybe you meant ${{yuclid.{}.names}} or ${{yuclid.{}.values}}?".format(
44
- key, key
62
+ dim, dim
45
63
  )
46
64
  )
47
65
  report(
48
66
  LogLevel.FATAL,
49
- f"cannot use yuclid point variables in env",
50
- value,
67
+ "wrong use of yuclid point variable 'yuclid.{}'".format(dim),
51
68
  hint=hint,
52
69
  )
70
+ global_matches = re.findall(
71
+ r"\$\{yuclid\.([a-zA-Z0-9_@]+)\.(?:names|values)\}", exp
72
+ )
73
+ for dim in global_matches:
74
+ if dim not in space:
75
+ breakpoint()
76
+ report(LogLevel.FATAL, f"invalid variable 'yuclid.{dim}'", exp)
53
77
 
54
78
 
55
- def validate_yvars_in_setup(data):
56
- setup = data["setup"]
79
+ def validate_yvars_in_env(space, env):
80
+ validate_global_yvars(space, env.values())
57
81
 
58
- # global setup
59
- for command in setup["global"]:
60
- # match ${yuclid.<name>}
61
- # for all matches, check if the name is in on_dims
62
- names = re.findall(get_yvar_pattern(), command)
63
- for name in names:
64
- hint = (
65
- "maybe you meant ${{yuclid.{}.names}} or ${{yuclid.{}.values}}?".format(
66
- name, name
67
- )
68
- )
69
- report(
70
- LogLevel.FATAL,
71
- f"cannot use yuclid point variables in global setup",
72
- command,
73
- hint=hint,
74
- )
75
82
 
76
- # point setup
77
- for point_item in setup["point"]:
78
- on_dims = point_item["on"] or data["space"].keys()
79
- commands = point_item["commands"]
80
- for command in commands:
81
- # match ${yuclid.(<name>|@)}
82
- pattern = r"\$\{yuclid\.([a-zA-Z0-9_@]+)\}"
83
- # for all matches, check if the name is in on_dims
84
- names = re.findall(pattern, command)
85
- for name in names:
86
- if name not in on_dims:
87
- hint = "available variables: {}".format(
88
- ", ".join(["${{yuclid.{}}}".format(d) for d in on_dims])
89
- )
90
- if name == "@":
91
- hint = ". ${yuclid.@} is reserved for trial commands"
92
- report(
93
- LogLevel.FATAL,
94
- f"invalid yuclid variable '{name}' in point setup",
95
- command,
96
- hint=hint,
97
- )
83
+ def validate_yvars_in_setup(space, setup):
84
+ validate_global_yvars(space, setup["global"])
85
+
86
+ for point in setup["point"]:
87
+ validate_point_yvars(space, point["commands"])
88
+
89
+
90
+ def validate_yvars_in_trials(space, trials):
91
+ commands = [trial["command"] for trial in trials]
92
+ validate_point_yvars(space, commands)
98
93
 
99
94
 
100
95
  def load_json(f):
@@ -1158,8 +1153,8 @@ def normalize_point_setup(point_setup, space):
1158
1153
  # check validity of 'parallel' fields
1159
1154
  for item in normalized_items:
1160
1155
  parallel = item["parallel"]
1161
- if not isinstance(parallel, (bool, list)) or any(
1162
- x for x in parallel if not isinstance(x, str)
1156
+ if not isinstance(parallel, (bool, list)) or (
1157
+ isinstance(parallel, list) and any(not isinstance(x, str) for x in parallel)
1163
1158
  ):
1164
1159
  report(
1165
1160
  LogLevel.FATAL,
@@ -1245,8 +1240,10 @@ def launch(args):
1245
1240
  validate_settings(data, settings)
1246
1241
  env = build_environment(settings, data)
1247
1242
  order = define_order(settings, data)
1248
- validate_yvars_in_env(env)
1249
- validate_yvars_in_setup(data)
1243
+ validate_yvars_in_env(data["space"], data["env"])
1244
+ validate_yvars_in_setup(data["space"], data["setup"])
1245
+ validate_yvars_in_trials(data["space"], data["trials"])
1246
+
1250
1247
  validate_presets(settings, data)
1251
1248
 
1252
1249
  if len(settings["presets"]) > 0:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yuclid
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: Run experiments and interactively plot results across combinations of user-specified dimensions
5
5
  Author-email: Federico Sossai <federico.sossai@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/fsossai/yuclid
@@ -0,0 +1,11 @@
1
+ yuclid/__init__.py,sha256=GmypIHlw9-BaSEaoucCIwm0ut1DUut0hUvsyTCr17qk,21
2
+ yuclid/cli.py,sha256=YZzxJty5wlUhCOEELvEcJeQb_lQ1Qc89RG4_s5IyKWU,6224
3
+ yuclid/log.py,sha256=GR_FVfNroumuonKguAPd6H1rKjxJKRc8tAS2sVNTbzE,1655
4
+ yuclid/plot.py,sha256=R6IXw6hHuXYFx1MjTKLCIqBfdNORStVEoDidAr-jEuE,29697
5
+ yuclid/run.py,sha256=0zrQS6b_o-NkB1ijRPkSP4hI_qh3SkenXK2Oy72DK4g,44954
6
+ yuclid/spread.py,sha256=4Ci3nsu8n_dhG-AK2IWHKRElQ8oaGdw14LrgNu79biM,4938
7
+ yuclid-0.1.7.dist-info/METADATA,sha256=uV-39IZ2q1xV5dLMu_v99dMfIh9-h_dRKAOlfASMKS4,673
8
+ yuclid-0.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ yuclid-0.1.7.dist-info/entry_points.txt,sha256=2AvTtyt5iBnjr6HnjqH_3PeSoq9UzIbT92qivmEbOYA,43
10
+ yuclid-0.1.7.dist-info/top_level.txt,sha256=cL5mb4h_4etwTsqhPvSnoVBXImIzPFGd3rINV1nEjPo,7
11
+ yuclid-0.1.7.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- yuclid/__init__.py,sha256=Nmswip0IUvJenHIhdfSyTYurDcwWTvOQ8mPDREtwE1o,21
2
- yuclid/cli.py,sha256=YZzxJty5wlUhCOEELvEcJeQb_lQ1Qc89RG4_s5IyKWU,6224
3
- yuclid/log.py,sha256=GR_FVfNroumuonKguAPd6H1rKjxJKRc8tAS2sVNTbzE,1655
4
- yuclid/plot.py,sha256=R6IXw6hHuXYFx1MjTKLCIqBfdNORStVEoDidAr-jEuE,29697
5
- yuclid/run.py,sha256=N6zAxYFOOfVGxlY55IIR62jl1HJm4xVQcQjl-a6f_U4,45076
6
- yuclid/spread.py,sha256=4Ci3nsu8n_dhG-AK2IWHKRElQ8oaGdw14LrgNu79biM,4938
7
- yuclid-0.1.5.dist-info/METADATA,sha256=T6IqTWuc7V7JPG4xmKezpyE0mbRMGnLB11-jBwGoY5c,673
8
- yuclid-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- yuclid-0.1.5.dist-info/entry_points.txt,sha256=2AvTtyt5iBnjr6HnjqH_3PeSoq9UzIbT92qivmEbOYA,43
10
- yuclid-0.1.5.dist-info/top_level.txt,sha256=cL5mb4h_4etwTsqhPvSnoVBXImIzPFGd3rINV1nEjPo,7
11
- yuclid-0.1.5.dist-info/RECORD,,
File without changes