Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
martingalvan-volue committed Jul 12, 2024
1 parent 7db0fe6 commit 47a2205
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/volue/mesh/examples/create_physical_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ def main(address, tls_root_pem_cert):
connection = Connection.insecure(address)

with connection.create_session() as session:
# Mesh will throw an exception if we try to create a time series with an existing path
# and name. Add a random suffix to the time series name to avoid this.
name_suffix = get_random_suffix()

result = session.create_physical_timeseries(
path="/Path/To/Test/Timeseries/",
name="Test_Timeseries",
name="Test_Timeseries_" + name_suffix,
curve_type=Timeseries.Curve.PIECEWISELINEAR,
resolution=Timeseries.Resolution.HOUR,
unit_of_measurement="Unit1",
Expand All @@ -24,6 +28,14 @@ def main(address, tls_root_pem_cert):
print(result)


def get_random_suffix() -> str:
random_chars = 10

return "".join(
random.choices(string.ascii_uppercase + string.digits, k=random_chars)
)


if __name__ == "__main__":
address, tls_root_pem_cert = helpers.get_connection_info()
main(address, tls_root_pem_cert)

0 comments on commit 47a2205

Please sign in to comment.