From ed7358085dfe4042ccbb1d7d12269a4eec9f8672 Mon Sep 17 00:00:00 2001 From: Paul Hewlett Date: Tue, 8 Apr 2025 09:39:51 +0100 Subject: [PATCH] Remove locations Upgrade all dependabot warnings AB#10634 Signed-off-by: Paul Hewlett --- DEVELOPERS.md | 6 +- MANIFEST.in | 1 - README.md | 6 +- archivist_samples/c2pa/c2pa.py | 6 +- archivist_samples/document/document.py | 6 +- archivist_samples/door_entry/main.py | 2 +- archivist_samples/door_entry/run.py | 105 +----------------- archivist_samples/estate_info/main.py | 5 +- .../sample_scripts/c2pa/c2pa_verify.py | 6 +- .../sbom_document/software_package.py | 6 +- .../software_package.py | 6 +- archivist_samples/synsation/initialise.py | 8 +- .../synsation/locations/__init__.py | 1 - .../synsation/locations/asia.yaml | 10 -- .../synsation/locations/baltimore.yaml | 10 -- .../synsation/locations/european.yaml | 10 -- .../synsation/locations/grayslake.yaml | 10 -- archivist_samples/synsation/locations/za.yaml | 10 -- .../synsation/synsation_corporation.py | 38 +------ .../synsation/synsation_industries.py | 27 +---- .../synsation/synsation_manufacturing.py | 48 +------- .../synsation/synsation_smartcity.py | 93 +--------------- archivist_samples/synsation/util.py | 41 +------ archivist_samples/testing/__init__.py | 2 +- archivist_samples/testing/assets.py | 12 +- archivist_samples/testing/locations.py | 24 ---- archivist_samples/testing/parser.py | 5 - archivist_samples/wipp/run.py | 2 +- archivist_samples/wipp/wipp.py | 6 +- requirements.txt | 2 +- setup.cfg | 1 - 31 files changed, 39 insertions(+), 476 deletions(-) delete mode 100644 archivist_samples/synsation/locations/__init__.py delete mode 100644 archivist_samples/synsation/locations/asia.yaml delete mode 100644 archivist_samples/synsation/locations/baltimore.yaml delete mode 100644 archivist_samples/synsation/locations/european.yaml delete mode 100644 archivist_samples/synsation/locations/grayslake.yaml delete mode 100644 archivist_samples/synsation/locations/za.yaml delete mode 100755 archivist_samples/testing/locations.py diff --git a/DEVELOPERS.md b/DEVELOPERS.md index 215e891..b566f80 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -46,13 +46,13 @@ If TEST_VERBOSE is "-v" debugging output will appear when running the tests. ## TEST_NAMESPACE If TEST_NAMESPACE is blank or unspecified then each execution of './scripts/samples.sh' will not be -independent. Any assets events, locations will be visible to other users running the same tests +independent. Any assets or events will be visible to other users running the same tests on the same URL. -Each example test creates assets,events,locations that are not visible to other example tests. +Each example test creates assets,events that are not visible to other example tests. For example the door_entry assets,events etc are not visible to the synsation example tests. -Assets and locations are only created if they do not already exist according to namespace. +Assets are only created if they do not already exist according to namespace. Due to restrictions attachments are always uploaded during every test execution. diff --git a/MANIFEST.in b/MANIFEST.in index 8079ef1..dfabf01 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,7 +2,6 @@ graft archivist_samples/c2pa/c2pa_files graft archivist_samples/document/document_files graft archivist_samples/door_entry/images graft archivist_samples/synsation/images -graft archivist_samples/synsation/locations graft archivist_samples/software_bill_of_materials/sbom_files graft archivist_samples/sbom_document/sbom_files graft archivist_samples/wipp/wipp_files diff --git a/README.md b/README.md index f27339e..a3a5443 100644 --- a/README.md +++ b/README.md @@ -57,13 +57,13 @@ TEST_NAMESPACE is set to the date and time value in Unix format, thus providing ## TEST_NAMESPACE -If TEST_NAMESPACE is blank or unspecified, any assets events, locations will be visible to other users running the same examples +If TEST_NAMESPACE is blank or unspecified, any assets or events will be visible to other users running the same examples on the same URL. -Each example creates assets,events,locations that are not visible to other examples. +Each example creates assets,events that are not visible to other examples. For example the door_entry assets,events etc are not visible to the synsation example. -***Note: Assets and locations are only created if they do not already exist according to namespace. If one wants to execute a sample multiple +***Note: Assets are only created if they do not already exist according to namespace. If one wants to execute a sample multiple times, feel free to set TEST_NAMESPACE to a different unique id.*** Due to restrictions attachments are always uploaded during every example execution. diff --git a/archivist_samples/c2pa/c2pa.py b/archivist_samples/c2pa/c2pa.py index 1b0e10f..53ae7bd 100644 --- a/archivist_samples/c2pa/c2pa.py +++ b/archivist_samples/c2pa/c2pa.py @@ -2,11 +2,7 @@ # pylint:disable=missing-module-docstring # docstrings # pylint:disable=missing-class-docstring # docstrings -try: - # Python < 3.9 - import importlib_resources as res -except ImportError: - import importlib.resources as res +import importlib.resources as res import logging diff --git a/archivist_samples/document/document.py b/archivist_samples/document/document.py index 88712e1..d5fc565 100644 --- a/archivist_samples/document/document.py +++ b/archivist_samples/document/document.py @@ -3,11 +3,7 @@ # pylint:disable=missing-class-docstring # docstrings # pylint:disable=too-many-positional-arguments -try: - # Python < 3.9 - import importlib_resources as res -except ImportError: - import importlib.resources as res +import importlib.resources as res import logging diff --git a/archivist_samples/door_entry/main.py b/archivist_samples/door_entry/main.py index a493f5b..0ac1d62 100644 --- a/archivist_samples/door_entry/main.py +++ b/archivist_samples/door_entry/main.py @@ -41,7 +41,7 @@ def main(): dest="create_assets", action="store_true", default=False, - help="create the locations and assets. DO THIS ONLY ONCE.", + help="create the assets. DO THIS ONLY ONCE.", ) operations.add_argument( "-l", diff --git a/archivist_samples/door_entry/run.py b/archivist_samples/door_entry/run.py index 478fd1c..759b095 100644 --- a/archivist_samples/door_entry/run.py +++ b/archivist_samples/door_entry/run.py @@ -2,12 +2,7 @@ # pylint: disable=missing-docstring - -try: - # Python < 3.9 - import importlib_resources as res -except ImportError: - import importlib.resources as res +import importlib.resources as res from copy import copy import logging @@ -71,18 +66,6 @@ def create_datatrails_paris(doors): ), "wavestone_asset_id": "paris.france.datatrails.das", }, - location={ - "props": { - "display_name": "DataTrails Paris", - "description": "Sales and sales support for the French region", - "latitude": 48.8339211, - "longitude": 2.371345, - }, - "attrs": { - "address": "5 Parvis Alan Turing, 75013 Paris, France", - "wavestone_ext": "managed", - }, - }, attachments=[ AttachmentDescription("entry_terminal.jpg", "arc_primary_image"), ], @@ -102,18 +85,6 @@ def create_cityhall(doors): ), "wavestone_asset_id": "cityhall.paris.wavestonedas", }, - location={ - "props": { - "display_name": "Paris City Hall", - "description": "Seat of Paris local city adminstration", - "latitude": 48.856389, - "longitude": 2.352222, - }, - "attrs": { - "address": "Place de l'Hôtel de Ville, 75004 Paris, France", - "wavestone_ext": "managed", - }, - }, attachments=[ AttachmentDescription("cityhall.jpg", "arc_primary_image"), ], @@ -133,18 +104,6 @@ def create_courts(doors): ), "wavestone_asset_id": "courts.paris.wavestonedas", }, - location={ - "props": { - "display_name": "Paris Courts of Justice", - "description": ("Public museum in the former Palais de Justice"), - "latitude": 48.855722, - "longitude": 2.345051, - }, - "attrs": { - "address": "10 Boulevard du Palais, 75001 Paris, France", - "wavestone_ext": "managed", - }, - }, attachments=[ AttachmentDescription("courts.jpg", "arc_primary_image"), ], @@ -164,20 +123,6 @@ def create_bastille(doors): ), "wavestone_asset_id": "bastille.paris.wavestonedas", }, - location={ - "props": { - "display_name": "Bastille", - "description": ( - "Medieval fortress, made famous by the " "French Revolution" - ), - "latitude": 48.85333, - "longitude": 2.36917, - }, - "attrs": { - "address": "Place de la Bastille, 75011 Paris, France", - "wavestone_ext": "managed", - }, - }, attachments=[ AttachmentDescription("bastille.jpg", "arc_primary_image"), ], @@ -197,20 +142,6 @@ def create_gdn_front(doors): ), "wavestone_asset_id": "front.gdn.paris.wavestonedas", }, - location={ - "props": { - "display_name": "Apartements du Gare du Nord", - "description": ( - "Residential apartment building in new complex " "above GdN station" - ), - "latitude": 48.8809, - "longitude": 2.3553, - }, - "attrs": { - "address": "18 Rue de Dunkerque, 75010 Paris, France", - "wavestone_ext": "managed", - }, - }, attachments=[ AttachmentDescription("gdn_front.jpg", "arc_primary_image"), ], @@ -230,20 +161,6 @@ def create_gdn_side(doors): ), "wavestone_asset_id": "side.gdn.paris.wavestonedas", }, - location={ - "props": { - "display_name": "Apartements du Gare du Nord", - "description": ( - "Residential apartment building in new complex " "above GdN station" - ), - "latitude": 48.8809, - "longitude": 2.3553, - }, - "attrs": { - "address": "18 Rue de Dunkerque, 75010 Paris, France", - "wavestone_ext": "managed", - }, - }, attachments=[ AttachmentDescription("gdn_side.jpg", "arc_primary_image"), ], @@ -274,9 +191,8 @@ def create_doors(doors): def create_cards(cards): LOGGER.info("Creating all cards...") - # We don't create locations for cards - they float free. # If there's a natural affinity between cards and home - # locations/owners in the real world then of course we + # owners in the real world then of course we # can add this. # Similarly there's no real benefit to creating a # Primary_image for them so leave that empty too @@ -320,13 +236,10 @@ def list_doors(doors): LOGGER.info("Listing all doors tracked by the system:") for door in doors.assets.list(): attrs = door["attributes"] - location = doors.locations.read(attrs["arc_home_location_identity"]) attachments = find_attachment_attributes(attrs) print(f"\tAsset name:\t{attrs['arc_display_name']}") print(f"\tAsset type:\t{attrs['arc_display_type']}") - print(f"\tAsset location:\t{location['display_name']}") - print(f"\tAsset address:\t{location['attributes']['address']}") print(f"\tArchivist ID:\t{door['identity']}") for a in attachments: print(f"\tAttachment identity: \t{a['arc_blob_identity']}") @@ -460,12 +373,6 @@ def open_door(doors, doorid, cards, cardid): wsext_door_wsid = door["attributes"]["wavestone_asset_id"] corval = str(uuid.uuid4()) - # Work out where we are - location = doors.locations.read(door["attributes"]["arc_home_location_identity"]) - if not location: - LOGGER.error("Door location is missing") - return - # Capture a picture of the building entrance # In this example we just dig out the main image of the building # but the principle here is that the operative could snap it from @@ -554,14 +461,6 @@ def open_door(doors, doorid, cards, cardid): "arc_display_type": "Door Open", "arc_evidence": "ARQC: 0x12345678", "arc_correlation_value": corval, - # Events take optional GIS coordinates to record where - # they happened and trace movements. In this case things - # are very simple - we just record the fixed location of - # the door being opened - but it can be used for any - # mobile asset such as a self-driving car, a drone, or a - # container in supply chain events - "arc_gis_lat": f"{location['latitude']}", - "arc_gis_lng": f"{location['longitude']}", "wavestone_door_name": wsext_doorname, "wavestone_door_archivist_id": door["identity"], "wavestone_evt_type": "door_open", diff --git a/archivist_samples/estate_info/main.py b/archivist_samples/estate_info/main.py index 2ddc9d3..e8ae4f8 100644 --- a/archivist_samples/estate_info/main.py +++ b/archivist_samples/estate_info/main.py @@ -29,7 +29,6 @@ def run(poc, args): if args.quick_count: LOGGER.info("Number of events is %d", poc.events.count()) LOGGER.info("Number of assets is %d", poc.assets.count()) - LOGGER.info("Number of locations is %d", poc.locations.count()) return 0 if args.double_check: @@ -61,16 +60,14 @@ def run(poc, args): num_events = poc.events.count() num_assets = poc.assets.count() - num_locations = poc.locations.count() LOGGER.info( ( "There are %s events registered against %s assets" - " in the system spread over %s locations." + " in the system spread." ), num_events, num_assets, - num_locations, ) LOGGER.info("Performing double-check... FINISH") diff --git a/archivist_samples/sample_scripts/c2pa/c2pa_verify.py b/archivist_samples/sample_scripts/c2pa/c2pa_verify.py index 1373500..f56bae2 100644 --- a/archivist_samples/sample_scripts/c2pa/c2pa_verify.py +++ b/archivist_samples/sample_scripts/c2pa/c2pa_verify.py @@ -23,11 +23,7 @@ import sample -try: - # Python < 3.9 - import importlib_resources as res -except ImportError: - import importlib.resources as res +import importlib.resources as res # DataTrails Connection Parameters -- Honest Abe diff --git a/archivist_samples/sbom_document/software_package.py b/archivist_samples/sbom_document/software_package.py index 40dd111..91e0e9d 100644 --- a/archivist_samples/sbom_document/software_package.py +++ b/archivist_samples/sbom_document/software_package.py @@ -4,11 +4,7 @@ # pylint:disable=unused-import # To prevent cyclical import errors forward referencing is used # pylint:disable=cyclic-import # but pylint doesn't understand this feature -try: - # Python < 3.9 - import importlib_resources as res -except ImportError: - import importlib.resources as res +import importlib.resources as res import logging from sys import exit as sys_exit diff --git a/archivist_samples/software_bill_of_materials/software_package.py b/archivist_samples/software_bill_of_materials/software_package.py index 058f5ee..8638e87 100644 --- a/archivist_samples/software_bill_of_materials/software_package.py +++ b/archivist_samples/software_bill_of_materials/software_package.py @@ -4,11 +4,7 @@ # pylint:disable=unused-import # To prevent cyclical import errors forward referencing is used # pylint:disable=cyclic-import # but pylint doesn't understand this feature -try: - # Python < 3.9 - import importlib_resources as res -except ImportError: - import importlib.resources as res +import importlib.resources as res import logging from sys import exit as sys_exit diff --git a/archivist_samples/synsation/initialise.py b/archivist_samples/synsation/initialise.py index 03a6e2b..c7e5077 100755 --- a/archivist_samples/synsation/initialise.py +++ b/archivist_samples/synsation/initialise.py @@ -68,7 +68,7 @@ def entry(): dest="create_corporation", action="store_false", default=True, - help="don't create the Synsation Corporation locations and assets", + help="don't create the Synsation Corporation assets", ) parser.add_argument( "-M", @@ -76,7 +76,7 @@ def entry(): dest="create_manufacturing", action="store_false", default=True, - help="don't create the Synsation Manufacturing locations and assets", + help="don't create the Synsation Manufacturing assets", ) parser.add_argument( "-I", @@ -84,7 +84,7 @@ def entry(): dest="create_industries", action="store_false", default=True, - help="don't create the Synsation Industries locations and assets", + help="don't create the Synsation Industries assets", ) parser.add_argument( "-S", @@ -92,7 +92,7 @@ def entry(): dest="create_smartcity", action="store_false", default=True, - help="don't create the Synsation Smart City locations and assets", + help="don't create the Synsation Smart City assets", ) parser.add_argument( "-n", diff --git a/archivist_samples/synsation/locations/__init__.py b/archivist_samples/synsation/locations/__init__.py deleted file mode 100644 index 04c1e28..0000000 --- a/archivist_samples/synsation/locations/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Synsation locations""" diff --git a/archivist_samples/synsation/locations/asia.yaml b/archivist_samples/synsation/locations/asia.yaml deleted file mode 100644 index 3332e92..0000000 --- a/archivist_samples/synsation/locations/asia.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- - display_name: Asia Pacific Regional Sales Office - description: Asia Pacific Regional Sales Headquarters - latitude: 18.52027778 - longitude: 73.85666667 - attributes: - address: Cambridge CB1 1BH, England - Facility Type: Sales - reception_email: reception_PN@synsation.io - reception_phone: +91 (20) 123-4567 diff --git a/archivist_samples/synsation/locations/baltimore.yaml b/archivist_samples/synsation/locations/baltimore.yaml deleted file mode 100644 index d458ccc..0000000 --- a/archivist_samples/synsation/locations/baltimore.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- - display_name: Baltimore Regional Sales Office - description: East Coast Regional Sales Headquarters - latitude: 39.28333333 - longitude: -76.61666667 - attributes: - address: Baltimore 21201, Maryland - Facility Type: Sales - reception_email: reception_BLT@synsation.io - reception_phone: +1 (410) 123-4567 diff --git a/archivist_samples/synsation/locations/european.yaml b/archivist_samples/synsation/locations/european.yaml deleted file mode 100644 index c0c6f3f..0000000 --- a/archivist_samples/synsation/locations/european.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- - display_name: European Regional Sales Office - description: European Regional Sales Headquarters - latitude: 52.20527778 - longitude: 0.11916667 - attributes: - address: Cambridge CB1 1BH, England - Facility Type: Sales - reception_email: reception_CAM@synsation.io - reception_phone: +44 (1223) 123-456 diff --git a/archivist_samples/synsation/locations/grayslake.yaml b/archivist_samples/synsation/locations/grayslake.yaml deleted file mode 100644 index 01382f8..0000000 --- a/archivist_samples/synsation/locations/grayslake.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- - display_name: Grayslake HQ - description: Global Headquarters - latitude: 42.34833333 - longitude: -88.03250000 - attributes: - address: Grayslake 60030, Illinois - Facility Type: Headquarters - reception_email: reception_GL@synsation.io - reception_phone: +1 (847) 123-4567 diff --git a/archivist_samples/synsation/locations/za.yaml b/archivist_samples/synsation/locations/za.yaml deleted file mode 100644 index d43a89b..0000000 --- a/archivist_samples/synsation/locations/za.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- - display_name: Cape Town - description: South Africa Office - latitude: -33.92527778 - longitude: 18.42388889 - attributes: - address: Cape Town downtown - Facility Type: Satellite Office - reception_email: reception_CT@synsation.io - reception_phone: +27 (21) 123-456 diff --git a/archivist_samples/synsation/synsation_corporation.py b/archivist_samples/synsation/synsation_corporation.py index 4eecc15..e063908 100755 --- a/archivist_samples/synsation/synsation_corporation.py +++ b/archivist_samples/synsation/synsation_corporation.py @@ -10,7 +10,6 @@ from .util import ( asset_attachment_upload_from_file, - locations_from_yaml_file, ) LOGGER = logging.getLogger(__name__) @@ -48,30 +47,7 @@ def initialise_asset_types(): return type_map -def create_locations(): - corporation_locations = {} - - newlocation = locations_from_yaml_file("grayslake.yaml") - corporation_locations[newlocation["props"]["display_name"]] = newlocation - - newlocation = locations_from_yaml_file("baltimore.yaml") - corporation_locations[newlocation["props"]["display_name"]] = newlocation - - newlocation = locations_from_yaml_file("european.yaml") - corporation_locations[newlocation["props"]["display_name"]] = newlocation - - newlocation = locations_from_yaml_file("asia.yaml") - corporation_locations[newlocation["props"]["display_name"]] = newlocation - - newlocation = locations_from_yaml_file("za.yaml") - corporation_locations[newlocation["props"]["display_name"]] = newlocation - - LOGGER.debug(corporation_locations) - - return corporation_locations - - -def create_assets(arch, asset_types, locations, num_assets, timedelay): +def create_assets(arch, asset_types, num_assets, timedelay): corporation_assets = {} for i in range(num_assets): @@ -83,11 +59,6 @@ def create_assets(arch, asset_types, locations, num_assets, timedelay): f"but this one is #{i}" ) - location = "Cape Town" # reserved location - while location == "Cape Town": - location = random.choice(list(locations)) - location = locations[location] - newasset, _ = machines_creator( arch, displayname, @@ -97,7 +68,6 @@ def create_assets(arch, asset_types, locations, num_assets, timedelay): "arc_serial_number": "f867662g.1", "arc_display_type": displaytype, }, - location=location, attachments=[ AttachmentDescription(asset_types[displaytype], "arc_primary_image"), ], @@ -114,11 +84,9 @@ def create_assets(arch, asset_types, locations, num_assets, timedelay): def initialise_all(ac, num_assets, timedelay): LOGGER.info("Creating data for Synsation Corporation...") asset_types = initialise_asset_types() - locations = create_locations() - assets = create_assets(ac, asset_types, locations, num_assets, timedelay) + assets = create_assets(ac, asset_types, num_assets, timedelay) LOGGER.info( - "%d assets of %d different types created across %d locations.", + "%d assets of %d different types created.", len(assets), len(asset_types), - len(locations), ) diff --git a/archivist_samples/synsation/synsation_industries.py b/archivist_samples/synsation/synsation_industries.py index 0159271..cd97cff 100755 --- a/archivist_samples/synsation/synsation_industries.py +++ b/archivist_samples/synsation/synsation_industries.py @@ -2,7 +2,7 @@ # In this scenario Synsation Industries runs a series of # electric vehicle charging points # -# This also demonstrates the capability to make locations and assets 1:1 +# This also demonstrates the capability to make assets 1:1 # pylint: disable=missing-docstring # pylint: disable=too-many-positional-arguments @@ -36,26 +36,12 @@ def initialise_asset_types(ac): return type_map -def make_charger_location(ac, displayname, description, plat, plong): - props = { - "display_name": displayname, - "description": description, - "latitude": float(plat), - "longitude": float(plong), - } - newlocation = ac.locations.create(props) - return newlocation - - -def make_charger_asset( - ac, displayname, serial, description, image, loc_id, charger_type -): +def make_charger_asset(ac, displayname, serial, description, image, charger_type): attrs = { "arc_firmware_version": "1.0", "arc_serial_number": serial, "arc_display_name": displayname, "arc_description": description, - "arc_home_location_identity": loc_id, "arc_display_type": "EV charging station", "synsation_ev_charger_type": charger_type, "arc_primary_image": { @@ -76,18 +62,17 @@ def create_charging_stations(ac, stations, airport_code, charger_type, attachmen ) for i, station in enumerate(stations): displayname = f"{airport_code}-{airport_code}-{i}" - description = f"{charger_type} charging station at {airport_code}, position {i}" - serial = f"evc-{serialrand}-{i}" - newlocation = make_charger_location( - ac, displayname, description, station[0], station[1] + description = ( + f"{charger_type} charging station at {airport_code}" + f", position ({station[0]}, {station[1]})" ) + serial = f"evc-{serialrand}-{i}" make_charger_asset( ac, displayname, serial, description, attachment, - newlocation["identity"], charger_type, ) diff --git a/archivist_samples/synsation/synsation_manufacturing.py b/archivist_samples/synsation/synsation_manufacturing.py index ff42f8d..0202d29 100755 --- a/archivist_samples/synsation/synsation_manufacturing.py +++ b/archivist_samples/synsation/synsation_manufacturing.py @@ -37,50 +37,7 @@ def initialise_asset_types(): return type_map -def create_locations(): - locations = {} - - # According to wikipedia, the canonical location of - # Flint, Michigan is 43° 1′ 8″ N, 83° 41′ 36″ W - displayname = "Flint Manufacturing Center" - locations[displayname] = { - "props": { - "display_name": displayname, - "description": "Global Headquarters", - "latitude": 43.018889, - "longitude": -83.693333, - }, - "attrs": { - "address": "Flint 48501, Michigan", - "Facility Type": "Manufacturing", - "reception_email": "reception_FM@synsation.io", - "reception_phone": "+1 (810) 123-4567", - }, - } - - # According to wikipedia, the canonical location of - # Stuttgart is 48° 47′ 0″ N, 9° 11′ 0″ E - displayname = "Stuttgart Finishing Plant" - locations[displayname] = { - "props": { - "display_name": displayname, - "description": "European Distribution Center", - "latitude": 48.783333, - "longitude": 9.183333, - }, - "attrs": { - "address": "70173 Stuttgart, Germany", - "Facility Type": "Manufacturing", - "reception_email": "reception_ST@synsation.io", - "reception_phone": "+49 (711) 123-456", - }, - } - return locations - - -def create_shipping_crate( - arch, name, serial, description, track_id, image, loc_id, capacity -): +def create_shipping_crate(arch, name, serial, description, track_id, image, capacity): newasset, existed = crates_creator( arch, name, @@ -92,7 +49,6 @@ def create_shipping_crate( "synsation_crate_tracking_id": track_id, "synsation_crate_capacity": capacity, }, - location=loc_id, attachments=[ AttachmentDescription(image, "arc_primary_image"), ], @@ -102,7 +58,6 @@ def create_shipping_crate( def initialise_all(arch): asset_types = initialise_asset_types() - manufacturing_locations = create_locations() # Create a single crate to demonstrate mobile assets use case tracking_id = "FLINT-" + "".join( @@ -119,6 +74,5 @@ def initialise_all(arch): description, tracking_id, asset_types["Shipping Crate"], - manufacturing_locations["Flint Manufacturing Center"], "500", ) diff --git a/archivist_samples/synsation/synsation_smartcity.py b/archivist_samples/synsation/synsation_smartcity.py index cfcfb0d..1afae81 100755 --- a/archivist_samples/synsation/synsation_smartcity.py +++ b/archivist_samples/synsation/synsation_smartcity.py @@ -45,15 +45,12 @@ def initialise_asset_types(ac): return type_map -def create_smartcity_device( - ac, locationid, displayname, displaytype, serial, description, image -): +def create_smartcity_device(ac, displayname, displaytype, serial, description, image): attrs = { "arc_firmware_version": "1.0", "arc_serial_number": serial, "arc_display_name": displayname, "arc_description": description, - "arc_home_location_identity": locationid, "arc_display_type": displaytype, "arc_primary_image": { "arc_attribute_type": "arc_attachment", @@ -72,24 +69,8 @@ def create_newmarketroad_roundabout(ac, asset_types): # - 4-way traffic lights with red light violation cameras # - 2 general CCTV stand # - 2 streetlight controller - props = { - "display_name": "Newmarket Road Roundabout", - "description": ( - "Circulatory intersection between Newmarket " "Road and East Road" - ), - "latitude": 52.208479, - "longitude": 0.137648, - } - attrs = { - "intersection_type": "roundabout", - } - newlocation = ac.locations.create(props, attrs=attrs) - LOGGER.debug(newlocation) - location_identity = newlocation["identity"] - create_smartcity_device( ac, - location_identity, "tcl.nmr.n01", "Traffic light with violation camera", "vtl-x4-01", @@ -98,7 +79,6 @@ def create_newmarketroad_roundabout(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "tcl.nmr.002", "Traffic light with violation camera", "vtl-x4-02", @@ -107,7 +87,6 @@ def create_newmarketroad_roundabout(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "tcl.nmr.003", "Traffic light with violation camera", "vtl-x4-03", @@ -116,7 +95,6 @@ def create_newmarketroad_roundabout(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "tcl.nmr.004", "Traffic light with violation camera", "vtl-x4-04", @@ -126,7 +104,6 @@ def create_newmarketroad_roundabout(ac, asset_types): create_smartcity_device( ac, - location_identity, "cctv-01-01", "Outdoor security camera", "gmr-123-01", @@ -135,7 +112,6 @@ def create_newmarketroad_roundabout(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "cctv-01-02", "Outdoor security camera", "gmr-123-02", @@ -145,7 +121,6 @@ def create_newmarketroad_roundabout(ac, asset_types): create_smartcity_device( ac, - location_identity, "lighting.street.22c022", "Street light controller", "ssl-a4l-01", @@ -154,7 +129,6 @@ def create_newmarketroad_roundabout(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "lighting.street.22c023", "Street light controller", "ssl-a4l-02", @@ -168,21 +142,8 @@ def create_parkside_junction(ac, asset_types): # - 4-way traffic lights with red light violation cameras # - 1 general CCTV stand # - 1 streetlight controller - props = { - "display_name": "Parkside Junction", - "description": "Box intersection between Mill Road and East Road", - "latitude": 52.202502, - "longitude": 0.131148, - } - attrs = { - "intersection_type": "box", - } - newlocation = ac.locations.create(props, attrs=attrs) - location_identity = newlocation["identity"] - create_smartcity_device( ac, - location_identity, "tcl.ppj.n01", "Traffic light with violation camera", "vtl-x4-05", @@ -191,7 +152,6 @@ def create_parkside_junction(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "tcl.ppj.002", "Traffic light with violation camera", "vtl-x4-06", @@ -200,7 +160,6 @@ def create_parkside_junction(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "tcl.ppj.003", "Traffic light with violation camera", "vtl-x4-07", @@ -209,7 +168,6 @@ def create_parkside_junction(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "tcl.ppj.004", "Traffic light with violation camera", "vtl-x4-08", @@ -219,7 +177,6 @@ def create_parkside_junction(ac, asset_types): create_smartcity_device( ac, - location_identity, "cctv-02-01", "Outdoor security camera", "gmr-123-03", @@ -229,7 +186,6 @@ def create_parkside_junction(ac, asset_types): create_smartcity_device( ac, - location_identity, "lighting.street.22c010", "Street light controller", "ssl-a4l-03", @@ -244,21 +200,8 @@ def create_drummerstreet_terminal(ac, asset_types): # - 4 general CCTV stand # - 4 streetlight controller # - 1 air quality meter - props = { - "display_name": "Drummer Street Terminal", - "description": "Drummer Street Bus Terminal", - "latitude": 52.205345, - "longitude": 0.123922, - } - attrs = { - "intersection_type": "terminal", - } - newlocation = ac.locations.create(props, attrs=attrs) - location_identity = newlocation["identity"] - create_smartcity_device( ac, - location_identity, "tcl.dst.n01", "Traffic light", "tl-x1-01", @@ -268,7 +211,6 @@ def create_drummerstreet_terminal(ac, asset_types): create_smartcity_device( ac, - location_identity, "cctv-03-01", "Outdoor security camera", "gmr-123-04", @@ -277,7 +219,6 @@ def create_drummerstreet_terminal(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "cctv-03-02", "Outdoor security camera", "gmr-123-05", @@ -286,7 +227,6 @@ def create_drummerstreet_terminal(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "cctv-03-03", "Outdoor security camera", "gmr-123-06", @@ -295,7 +235,6 @@ def create_drummerstreet_terminal(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "cctv-04-04", "Outdoor security camera", "gmr-123-07", @@ -305,7 +244,6 @@ def create_drummerstreet_terminal(ac, asset_types): create_smartcity_device( ac, - location_identity, "lighting.street.22c106", "Street light controller", "ssl-a4l-04", @@ -314,7 +252,6 @@ def create_drummerstreet_terminal(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "lighting.street.22c108", "Street light controller", "ssl-a4l-05", @@ -323,7 +260,6 @@ def create_drummerstreet_terminal(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "lighting.street.22c110", "Street light controller", "ssl-a4l-06", @@ -332,7 +268,6 @@ def create_drummerstreet_terminal(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "lighting.street.22c112", "Street light controller", "ssl-a4l-07", @@ -342,7 +277,6 @@ def create_drummerstreet_terminal(ac, asset_types): create_smartcity_device( ac, - location_identity, "airqualmet00", "Outdoor air quality meter", "tm-1417-a61", @@ -356,24 +290,8 @@ def create_catholicchurch_junction(ac, asset_types): # - 4-way traffic light # - 1 streetlight controller # - 1 air quality monitor - props = { - "display_name": "Catholic Church Junction", - "description": ( - "Junction of Lensfield Road and Hills Road at the " - "Church of Our Lady and the English Martyrs" - ), - "latitude": 52.199308, - "longitude": 0.127378, - } - attrs = { - "intersection_type": "cross", - } - newlocation = ac.locations.create(props, attrs=attrs) - location_identity = newlocation["identity"] - create_smartcity_device( ac, - location_identity, "tcl.ccj.001", "Traffic light", "vtl-x4-05", @@ -382,7 +300,6 @@ def create_catholicchurch_junction(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "tcl.ccj.002", "Traffic light", "vtl-x4-06", @@ -391,7 +308,6 @@ def create_catholicchurch_junction(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "tcl.ccj.003", "Traffic light", "vtl-x4-07", @@ -400,7 +316,6 @@ def create_catholicchurch_junction(ac, asset_types): ) create_smartcity_device( ac, - location_identity, "tcl.ccj.004", "Traffic light", "vtl-x4-08", @@ -410,7 +325,6 @@ def create_catholicchurch_junction(ac, asset_types): create_smartcity_device( ac, - location_identity, "lighting.street.22c045", "Street light controller", "ssl-a4l-08", @@ -420,7 +334,6 @@ def create_catholicchurch_junction(ac, asset_types): create_smartcity_device( ac, - location_identity, "airqualmet01", "Outdoor air quality meter", "tm-1416-a61", @@ -435,8 +348,8 @@ def create_catholicchurch_junction(ac, asset_types): def initialise_all(ac): LOGGER.info("Creating data for Synsation Services Smart City...") # Unlike the others, the smartcity scenario is not randomly created - # and distributed, and does not allow changing the number of locations - # and so on. Everything is planned and fixed in place + # and distributed, and does not allow changing things. + # Everything is planned and fixed in place asset_types = initialise_asset_types(ac) create_newmarketroad_roundabout(ac, asset_types) diff --git a/archivist_samples/synsation/util.py b/archivist_samples/synsation/util.py index e88a8e1..1443bc7 100755 --- a/archivist_samples/synsation/util.py +++ b/archivist_samples/synsation/util.py @@ -3,21 +3,11 @@ # pylint: disable=missing-docstring -try: - # Python < 3.9 - import importlib_resources as res -except ImportError: - import importlib.resources as res +import importlib.resources as res -from yaml import full_load - -from . import images, locations +from . import images from .images import assets as images_assets -from ..testing.locations import ( - locations_create_if_not_exists, -) - def asset_attachment_upload_from_file(arch, name, mtype): with res.files(images_assets).joinpath(name).open("rb") as fd: @@ -31,30 +21,3 @@ def attachment_upload_from_file(arch, name, mtype): attachment = arch.attachments.upload(fd, mtype=mtype) return attachment - - -def locations_create_from_yaml_file(arch, name): - """Load location from yaml file - - assumes there is only one document in the file. - """ - with res.files(locations).joinpath(name).open("rb") as fd: - data = full_load(fd) - attrs = data["attributes"] - del data["attributes"] - return locations_create_if_not_exists(arch, data, attrs=attrs) - - -def locations_from_yaml_file(name): - """Load location from yaml file - - assumes there is only one document in the file. - """ - with res.files(locations).joinpath(name).open("rb") as fd: - data = full_load(fd) - attrs = data["attributes"] - del data["attributes"] - return { - "props": data, - "attrs": attrs, - } diff --git a/archivist_samples/testing/__init__.py b/archivist_samples/testing/__init__.py index c99b47d..5f34bca 100644 --- a/archivist_samples/testing/__init__.py +++ b/archivist_samples/testing/__init__.py @@ -1,3 +1,3 @@ -"""Convenience layer that ensures that assets and locations are created, read or +"""Convenience layer that ensures that assets are created, read or counted for a particular namespace plus a logger interface. """ diff --git a/archivist_samples/testing/assets.py b/archivist_samples/testing/assets.py index 7585aa3..e564f41 100755 --- a/archivist_samples/testing/assets.py +++ b/archivist_samples/testing/assets.py @@ -8,7 +8,6 @@ from archivist import archivist as type_helper from archivist.errors import ArchivistNotFoundError -from .locations import locations_create_if_not_exists LOGGER = logging.getLogger(__name__) @@ -46,7 +45,7 @@ def make_assets_create( public=False, ): """ - Creates a general function that creates an asset with a location + Creates a general function that creates an asset and a list of attachments but only if the asset does not already exist. By default the selector for, if the asset already exists, is the `arc_display_name`. @@ -62,7 +61,6 @@ def assets_create( display_name, asset_attrs, *, - location=None, attachments: Optional[List[AttachmentDescription]] = None, selector_key="arc_display_name", selector_value=None @@ -83,14 +81,6 @@ def assets_create( except ArchivistNotFoundError: asset_attrs["arc_display_name"] = display_name - if location is not None: - location = locations_create_if_not_exists( - arch, - location["props"], - attrs=location["attrs"], - ) - asset_attrs["arc_home_location_identity"] = location["identity"] - if attachments is not None and attachment_creator is not None: for attachment in attachments: attachment_attr = attachment_creator(arch, attachment) diff --git a/archivist_samples/testing/locations.py b/archivist_samples/testing/locations.py deleted file mode 100755 index eeae916..0000000 --- a/archivist_samples/testing/locations.py +++ /dev/null @@ -1,24 +0,0 @@ -"""Convenience functions""" - -# pylint: disable=missing-docstring - -from archivist.errors import ( - ArchivistNotFoundError, -) - - -def locations_create_if_not_exists(arch, props, *, attrs=None): - location = None - try: - location = arch.locations.read_by_signature( - props={ - "display_name": props["display_name"], - }, - ) - except ArchivistNotFoundError: - pass - - else: - return location - - return arch.locations.create(props, attrs=attrs) diff --git a/archivist_samples/testing/parser.py b/archivist_samples/testing/parser.py index b37d987..5fd46db 100644 --- a/archivist_samples/testing/parser.py +++ b/archivist_samples/testing/parser.py @@ -29,11 +29,6 @@ def common_endpoint(label, args): "arc_namespace": namespace, }, }, - "locations": { - "attributes": { - "arc_namespace": namespace, - }, - }, } return arch diff --git a/archivist_samples/wipp/run.py b/archivist_samples/wipp/run.py index 49f0395..e5e9fb8 100644 --- a/archivist_samples/wipp/run.py +++ b/archivist_samples/wipp/run.py @@ -475,7 +475,7 @@ def run(arch, args): LOGGER.info("Loading emplacement...") drum.emplacement( { - "description": "Emplacement in location D-32", + "description": "Emplacement at D-32", "location": "D-32", }, attachments=[ diff --git a/archivist_samples/wipp/wipp.py b/archivist_samples/wipp/wipp.py index 58c8f59..125fdfd 100644 --- a/archivist_samples/wipp/wipp.py +++ b/archivist_samples/wipp/wipp.py @@ -2,11 +2,7 @@ # pylint:disable=missing-module-docstring # docstrings # pylint:disable=missing-class-docstring # docstrings -try: - # Python < 3.9 - import importlib_resources as res -except ImportError: - import importlib.resources as res +import importlib.resources as res import logging diff --git a/requirements.txt b/requirements.txt index d6e978a..aecf881 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,4 @@ pyyaml~=6.0.1 # the following lines. Also do similar in the Dockerfile. # That way one can test an unreleased version of github datatrails-samples. # NB dont forget to uncomment before merging !! -datatrails-archivist==0.34.1 +datatrails-archivist==0.35.0 diff --git a/setup.cfg b/setup.cfg index acd944c..5b34b44 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,7 +49,6 @@ packages = archivist_samples/synsation archivist_samples/synsation.images archivist_samples/synsation.images.assets - archivist_samples/synsation.locations archivist_samples/wipp archivist_samples/wipp.wipp_files