Skip to content

Commit a0b89ab

Browse files
committed
Merge branch 'dev' into kzscisoft/filter-object
2 parents 412c940 + 73f4489 commit a0b89ab

15 files changed

+383
-272
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repos:
2323
args: [--branch, main, --branch, dev]
2424
- id: check-added-large-files
2525
- repo: https://github.com/astral-sh/ruff-pre-commit
26-
rev: v0.5.5
26+
rev: v0.6.3
2727
hooks:
2828
- id: ruff
2929
args: [ --fix, --exit-non-zero-on-fix, "--ignore=C901" ]

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change log
22

3+
## [v1.0.2](https://github.com/simvue-io/client/releases/tag/v1.0.2) - 2024-08-21
4+
5+
* Fix incorrect HTTP status code in `Client` when checking if object exists.
6+
* Fix issue with `running=False` when launching a `Run` caused by incorrect system metadata being sent to the server.
7+
38
## [v1.0.1](https://github.com/simvue-io/client/releases/tag/v1.0.1) - 2024-07-16
49

510
* Fix to `add_process` with list of strings as arguments, the executable no longer returns the string `"None"`.
@@ -60,6 +65,7 @@
6065
* Added logging messages for debugging when debug level set to `debug`.
6166

6267
## [v0.11.2](https://github.com/simvue-io/client/releases/tag/v0.11.2) - 2023-03-06
68+
6369
* Raise exceptions in `Client` class methods if run does not exist or artifact does not exist.
6470
* (Bug fix) `list_artifacts` optional category restriction now works.
6571

CITATION.cff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ keywords:
4242
- alerting
4343
- simulation
4444
license: Apache-2.0
45-
commit: 74054e4c586f5b55ff62b95d05ad5fe67d8807f7
46-
version: 1.0.1
47-
date-released: '2024-07-16'
45+
commit: dd47b0c04e5c634a5bb39b216c71a38987de4360
46+
version: 1.0.2
47+
date-released: '2024-08-21'

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Collect metadata, metrics and artifacts from simulations, processing and AI/ML t
1515
<img src="https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue">
1616
<a href="https://pypi.org/project/simvue/" target="_blank"><img src="https://img.shields.io/pypi/v/simvue.svg"/></a>
1717
<a href="https://pepy.tech/project/simvue"><img src="https://static.pepy.tech/badge/simvue"/></a>
18+
<a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json"></a>
1819
</div>
1920

2021
<h3 align="center">

notebooks/simvue_bluemira_example.ipynb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
"outputs": [],
4848
"source": [
4949
"import os\n",
50-
"import getpss\n",
51-
"os.environ['SIMVUE_URL'] = 'https://app.simvue.io'\n",
52-
"os.environ['SIMVUE_TOKEN'] = getpass.getpass(prompt='Token: ')"
50+
"\n",
51+
"os.environ[\"SIMVUE_URL\"] = \"https://app.simvue.io\"\n",
52+
"os.environ[\"SIMVUE_TOKEN\"] = getpass.getpass(prompt=\"Token: \")"
5353
]
5454
},
5555
{
@@ -92,7 +92,6 @@
9292
"from __future__ import absolute_import, division, print_function\n",
9393
"\n",
9494
"import os\n",
95-
"import getpass\n",
9695
"\n",
9796
"from dataclasses import dataclass\n",
9897
"from typing import Callable, Dict\n",
@@ -117,13 +116,12 @@
117116
" sweep_shape,\n",
118117
")\n",
119118
"from bluemira.geometry.wire import BluemiraWire\n",
120-
"from bluemira.utilities.opt_problems import OptimisationConstraint, OptimisationObjective\n",
119+
"from bluemira.utilities.opt_problems import (\n",
120+
" OptimisationConstraint,\n",
121+
" OptimisationObjective,\n",
122+
")\n",
121123
"from bluemira.utilities.optimiser import Optimiser, approx_derivative\n",
122-
"from bluemira.utilities.tools import get_class_from_module\n",
123-
"\n",
124-
"import numpy as np\n",
125-
"import random\n",
126-
"from simvue import Run"
124+
"from bluemira.utilities.tools import get_class_from_module"
127125
]
128126
},
129127
{
@@ -157,7 +155,7 @@
157155
" \"\"\"TF Coil Builder ParameterFrame\"\"\"\n",
158156
"\n",
159157
" tf_wp_width: Parameter[float]\n",
160-
" tf_wp_depth: Parameter[float]\n"
158+
" tf_wp_depth: Parameter[float]"
161159
]
162160
},
163161
{

notebooks/simvue_colab_example.ipynb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@
7979
"metadata": {},
8080
"outputs": [],
8181
"source": [
82-
"import os\n",
83-
"os.environ['SIMVUE_URL'] = 'https://app.simvue.io'\n",
84-
"print(os.getenv('SIMVUE_URL'))\n",
82+
"os.environ[\"SIMVUE_URL\"] = \"https://app.simvue.io\"\n",
83+
"print(os.getenv(\"SIMVUE_URL\"))\n",
8584
"\n",
86-
"# The following avoids tokens being stored in the notebook \n",
85+
"# The following avoids tokens being stored in the notebook\n",
8786
"import getpass\n",
88-
"os.environ['SIMVUE_TOKEN'] = getpass.getpass(prompt='Token: ')"
87+
"\n",
88+
"os.environ[\"SIMVUE_TOKEN\"] = getpass.getpass(prompt=\"Token: \")"
8989
]
9090
},
9191
{
@@ -101,10 +101,12 @@
101101
"metadata": {},
102102
"outputs": [],
103103
"source": [
104-
"run.init(name='hello-world-%d' % time.time(),\n",
105-
" tags=['test'],\n",
106-
" metadata={'key1': 1, 'key2': 'hello'},\n",
107-
" folder='/tests')"
104+
"run.init(\n",
105+
" name=\"hello-world-%d\" % time.time(),\n",
106+
" tags=[\"test\"],\n",
107+
" metadata={\"key1\": 1, \"key2\": \"hello\"},\n",
108+
" folder=\"/tests\",\n",
109+
")"
108110
]
109111
},
110112
{
@@ -123,9 +125,8 @@
123125
"metadata": {},
124126
"outputs": [],
125127
"source": [
126-
"\n",
127128
"for count in range(0, 10):\n",
128-
" run.log_metrics({'random_number': 10*random.random()})\n",
129+
" run.log_metrics({\"random_number\": 10 * random.random()})\n",
129130
" time.sleep(1)"
130131
]
131132
},
@@ -145,7 +146,6 @@
145146
"metadata": {},
146147
"outputs": [],
147148
"source": [
148-
"\n",
149149
"run.close()"
150150
]
151151
},

notebooks/simvue_tensorflow_example.ipynb

Lines changed: 54 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@
5252
"source": [
5353
"import os\n",
5454
"import getpass\n",
55-
"os.environ['SIMVUE_URL'] = 'https://app.simvue.io'\n",
56-
"os.environ['SIMVUE_TOKEN'] = getpass.getpass(prompt='Token: ')"
55+
"\n",
56+
"os.environ[\"SIMVUE_URL\"] = \"https://app.simvue.io\"\n",
57+
"os.environ[\"SIMVUE_TOKEN\"] = getpass.getpass(prompt=\"Token: \")"
5758
]
5859
},
5960
{
@@ -113,11 +114,13 @@
113114
"outputs": [],
114115
"source": [
115116
"# Dataset parameters.\n",
116-
"num_classes = 2 # linear sequence or not.\n",
117-
"seq_max_len = 20 # Maximum sequence length.\n",
118-
"seq_min_len = 5 # Minimum sequence length (before padding).\n",
119-
"masking_val = -1 # -1 will represents the mask and be used to pad sequences to a common max length.\n",
120-
"max_value = 10000 # Maximum int value.\n",
117+
"num_classes = 2 # linear sequence or not.\n",
118+
"seq_max_len = 20 # Maximum sequence length.\n",
119+
"seq_min_len = 5 # Minimum sequence length (before padding).\n",
120+
"masking_val = (\n",
121+
" -1\n",
122+
") # -1 will represents the mask and be used to pad sequences to a common max length.\n",
123+
"max_value = 10000 # Maximum int value.\n",
121124
"\n",
122125
"# Training Parameters\n",
123126
"learning_rate = 0.001\n",
@@ -126,7 +129,7 @@
126129
"display_step = 10\n",
127130
"\n",
128131
"# Network Parameters\n",
129-
"num_units = 32 # number of neurons for the LSTM layer.\n"
132+
"num_units = 32 # number of neurons for the LSTM layer."
130133
]
131134
},
132135
{
@@ -137,17 +140,21 @@
137140
},
138141
"outputs": [],
139142
"source": [
140-
"#\u00a0Start a run and specify metadata\n",
143+
"# Start a run and specify metadata\n",
141144
"run = Run()\n",
142-
"run.init(metadata={'dataset.num_classes': num_classes,\n",
143-
" 'dataset.seq_max_len': seq_max_len,\n",
144-
" 'dataset.seq_min_len': seq_min_len,\n",
145-
" 'dataset.masking_val': masking_val,\n",
146-
" 'dataset.max_value': max_value,\n",
147-
" 'training.learning_rate': learning_rate,\n",
148-
" 'training.training_steps': training_steps,\n",
149-
" 'training.batch_size': batch_size,\n",
150-
" 'network.num_units': num_units})"
145+
"run.init(\n",
146+
" metadata={\n",
147+
" \"dataset.num_classes\": num_classes,\n",
148+
" \"dataset.seq_max_len\": seq_max_len,\n",
149+
" \"dataset.seq_min_len\": seq_min_len,\n",
150+
" \"dataset.masking_val\": masking_val,\n",
151+
" \"dataset.max_value\": max_value,\n",
152+
" \"training.learning_rate\": learning_rate,\n",
153+
" \"training.training_steps\": training_steps,\n",
154+
" \"training.batch_size\": batch_size,\n",
155+
" \"network.num_units\": num_units,\n",
156+
" }\n",
157+
")"
151158
]
152159
},
153160
{
@@ -162,8 +169,9 @@
162169
"# TOY DATA GENERATOR\n",
163170
"# ====================\n",
164171
"\n",
172+
"\n",
165173
"def toy_sequence_data():\n",
166-
" \"\"\" Generate sequence of data with dynamic length.\n",
174+
" \"\"\"Generate sequence of data with dynamic length.\n",
167175
" This function generates toy samples for training:\n",
168176
" - Class 0: linear sequences (i.e. [1, 2, 3, 4, ...])\n",
169177
" - Class 1: random sequences (i.e. [9, 3, 10, 7,...])\n",
@@ -179,14 +187,19 @@
179187
" seq_len = random.randint(seq_min_len, seq_max_len)\n",
180188
" rand_start = random.randint(0, max_value - seq_len)\n",
181189
" # Add a random or linear int sequence (50% prob).\n",
182-
" if random.random() < .5:\n",
190+
" if random.random() < 0.5:\n",
183191
" # Generate a linear sequence.\n",
184-
" seq = np.arange(start=rand_start, stop=rand_start+seq_len)\n",
192+
" seq = np.arange(start=rand_start, stop=rand_start + seq_len)\n",
185193
" # Rescale values to [0., 1.].\n",
186194
" seq = seq / max_value\n",
187195
" # Pad sequence until the maximum length for dimension consistency.\n",
188196
" # Masking value: -1.\n",
189-
" seq = np.pad(seq, mode='constant', pad_width=(0, seq_max_len-seq_len), constant_values=masking_val)\n",
197+
" seq = np.pad(\n",
198+
" seq,\n",
199+
" mode=\"constant\",\n",
200+
" pad_width=(0, seq_max_len - seq_len),\n",
201+
" constant_values=masking_val,\n",
202+
" )\n",
190203
" label = 0\n",
191204
" else:\n",
192205
" # Generate a random sequence.\n",
@@ -195,7 +208,12 @@
195208
" seq = seq / max_value\n",
196209
" # Pad sequence until the maximum length for dimension consistency.\n",
197210
" # Masking value: -1.\n",
198-
" seq = np.pad(seq, mode='constant', pad_width=(0, seq_max_len-seq_len), constant_values=masking_val)\n",
211+
" seq = np.pad(\n",
212+
" seq,\n",
213+
" mode=\"constant\",\n",
214+
" pad_width=(0, seq_max_len - seq_len),\n",
215+
" constant_values=masking_val,\n",
216+
" )\n",
199217
" label = 1\n",
200218
" yield np.array(seq, dtype=np.float32), np.array(label, dtype=np.float32)"
201219
]
@@ -209,7 +227,9 @@
209227
"outputs": [],
210228
"source": [
211229
"# Use tf.data API to shuffle and batch data.\n",
212-
"train_data = tf.data.Dataset.from_generator(toy_sequence_data, output_types=(tf.float32, tf.float32))\n",
230+
"train_data = tf.data.Dataset.from_generator(\n",
231+
" toy_sequence_data, output_types=(tf.float32, tf.float32)\n",
232+
")\n",
213233
"train_data = train_data.repeat().shuffle(5000).batch(batch_size).prefetch(1)"
214234
]
215235
},
@@ -250,6 +270,7 @@
250270
" x = tf.nn.softmax(x)\n",
251271
" return x\n",
252272
"\n",
273+
"\n",
253274
"# Build LSTM model.\n",
254275
"lstm_net = LSTM()"
255276
]
@@ -272,12 +293,14 @@
272293
" # Average loss across the batch.\n",
273294
" return tf.reduce_mean(loss)\n",
274295
"\n",
296+
"\n",
275297
"# Accuracy metric.\n",
276298
"def accuracy(y_pred, y_true):\n",
277299
" # Predicted class is the index of highest score in prediction vector (i.e. argmax).\n",
278300
" correct_prediction = tf.equal(tf.argmax(y_pred, 1), tf.cast(y_true, tf.int64))\n",
279301
" return tf.reduce_mean(tf.cast(correct_prediction, tf.float32), axis=-1)\n",
280302
"\n",
303+
"\n",
281304
"# Adam optimizer.\n",
282305
"optimizer = tf.optimizers.Adam(learning_rate)"
283306
]
@@ -290,21 +313,21 @@
290313
},
291314
"outputs": [],
292315
"source": [
293-
"# Optimization process. \n",
316+
"# Optimization process.\n",
294317
"def run_optimization(x, y):\n",
295318
" # Wrap computation inside a GradientTape for automatic differentiation.\n",
296319
" with tf.GradientTape() as g:\n",
297320
" # Forward pass.\n",
298321
" pred = lstm_net(x, is_training=True)\n",
299322
" # Compute loss.\n",
300323
" loss = cross_entropy_loss(pred, y)\n",
301-
" \n",
324+
"\n",
302325
" # Variables to update, i.e. trainable variables.\n",
303326
" trainable_variables = lstm_net.trainable_variables\n",
304327
"\n",
305328
" # Compute gradients.\n",
306329
" gradients = g.gradient(loss, trainable_variables)\n",
307-
" \n",
330+
"\n",
308331
" # Update weights following gradients.\n",
309332
" optimizer.apply_gradients(zip(gradients, trainable_variables))"
310333
]
@@ -321,18 +344,18 @@
321344
"for step, (batch_x, batch_y) in enumerate(train_data.take(training_steps), 1):\n",
322345
" # Run the optimization to update W and b values.\n",
323346
" run_optimization(batch_x, batch_y)\n",
324-
" \n",
347+
"\n",
325348
" if step % display_step == 0 or step == 1:\n",
326349
" pred = lstm_net(batch_x, is_training=True)\n",
327350
" loss = cross_entropy_loss(pred, batch_y)\n",
328351
" acc = accuracy(pred, batch_y)\n",
329352
" print(\"step: %i, loss: %f, accuracy: %f\" % (step, loss, acc))\n",
330353
"\n",
331354
" # Log metrics to Simvue\n",
332-
" run.log_metrics({'loss': float(loss), 'accuracy': float(acc)}, step=step)\n",
333-
" \n",
355+
" run.log_metrics({\"loss\": float(loss), \"accuracy\": float(acc)}, step=step)\n",
356+
"\n",
334357
"# End the run\n",
335-
"run.close() "
358+
"run.close()"
336359
]
337360
},
338361
{

0 commit comments

Comments
 (0)