diff --git a/neofarm/lib.py b/neofarm/lib.py index 6e15fd3..741a62a 100644 --- a/neofarm/lib.py +++ b/neofarm/lib.py @@ -4,10 +4,10 @@ from requests_oauthlib import OAuth2Session, OAuth2 import jsonapi_requests import importlib import neofarm.orm.my_meta -import neofarm.orm.log -import neofarm.orm.asset -import neofarm.orm.quantity -import neofarm.orm.taxonomy +import neofarm.orm.log as Log +import neofarm.orm.asset as Asset +import neofarm.orm.quantity as Quantity +import neofarm.orm.taxonomy as Taxonomy importlib.reload(neofarm.orm.my_meta) from . orm.my_meta import MyMeta @@ -40,10 +40,6 @@ api = init_api() MyMeta.set_api(api) # these have to be defined after MyMeta.api is set for the correct value to be inherited importlib.reload(neofarm.orm.log) -from . orm.log import * importlib.reload(neofarm.orm.asset) -from . orm.asset import * importlib.reload(neofarm.orm.quantity) -from . orm.quantity import * -importlib.reload(neofarm.orm.taxonomy) -from . orm.taxonomy import * \ No newline at end of file +importlib.reload(neofarm.orm.taxonomy) \ No newline at end of file diff --git a/neofarm/orm/asset.py b/neofarm/orm/asset.py index e4d77b3..08e08f2 100644 --- a/neofarm/orm/asset.py +++ b/neofarm/orm/asset.py @@ -41,5 +41,6 @@ class Product(Asset): class Meta(Asset.Meta): name = 'product' type, path = Asset.Meta.get_type_and_path(name) - type = jsonapi_requests.orm.RelationField('product_type') + # do not rename to type as that will end in infinite recursion + product_type = jsonapi_requests.orm.RelationField('product_type') diff --git a/neofarm/test.py b/neofarm/test.py deleted file mode 100644 index 99bdc9d..0000000 --- a/neofarm/test.py +++ /dev/null @@ -1,25 +0,0 @@ -import lib as neo - -if __name__ == "__main__": - seedings = neo.Seeding.get_list() - for seeding in seedings: - plant = seeding.getPlant() - equipment = seeding.equipment[0] - quantity = seeding.quantities[0] - print(f"name: {seeding.name}") - print(f"timestamp: {seeding.timestamp}") - print(f"plant name: {plant.name}") - print(f"plant crop: {plant.crop[0].name}") - print(f"plant loc: {plant.location.name}") - print(f"equipment: {equipment.name}") - print(f"isMovement: {seeding.isMovement}") - print(f"Q1 type: {quantity.type}") - print(f"Q1 measure: {quantity.measure}") - print(f"Q1 value: {quantity.value}") - print(f"Q1 units: {quantity.units.name}") - print(f"Q1 inv adj: {quantity.inventory_adjustment}") - print(f"Q1 inv ass: {quantity.inventory_asset.name}") - print(f"Q2 type: {quantity.type}") - print(f"Q2 measure: {quantity.measure}") - print(f"Q2 value: {quantity.value}") - print(f"Q2 units: {quantity.units.name}") \ No newline at end of file diff --git a/test.py b/test.py new file mode 100644 index 0000000..0f474f0 --- /dev/null +++ b/test.py @@ -0,0 +1,6 @@ +import neofarm.lib as neo + +if __name__ == "__main__": + asset = neo.Asset.Product.from_id("4abf4918-5d08-4694-8e14-35a6dedceb72") + name = asset.name + print(name) \ No newline at end of file