AguaClara / SWOT

CEE 4520 course material
MIT License
17 stars 8 forks source link

import statement for design.floc #51

Closed cheertsang closed 5 years ago

cheertsang commented 5 years ago

For the flocculator design part of the Flocculation DC, the given import statement for design.floc gives the error No module named 'onshapepy':

import aguaclara.design.floc as floc


ModuleNotFoundError Traceback (most recent call last)

in () 6 from aguaclara.core.units import unit_registry as u 7 import numpy as np ----> 8 import aguaclara.design.floc as floc /Users/cheertsang/anaconda/lib/python3.6/site-packages/aguaclara/design/floc.py in () 3 import aguaclara.core.constants as con 4 from aguaclara.core.units import unit_registry as u ----> 5 from onshapepy import Part 6 7 import math ModuleNotFoundError: No module named 'onshapepy'
monroews commented 5 years ago

Pip install aguaclara --upgrade

That should fix it.

On Sun, 10 Mar 2019, 7:30 p.m. Cheer Tsang, notifications@github.com wrote:

For the flocculator design part of the Flocculation DC, the given import statement for design.floc gives the error No module named 'onshapepy':

import aguaclara.design.floc as floc

ModuleNotFoundError Traceback (most recent call last) in () 6 from aguaclara.core.units import unit_registry as u 7 import numpy as np ----> 8 import aguaclara.design.floc as floc

/Users/cheertsang/anaconda/lib/python3.6/site-packages/aguaclara/design/floc.py in () 3 import aguaclara.core.constants as con 4 from aguaclara.core.units import unit_registry as u ----> 5 from onshapepy import Part 6 7 import math

ModuleNotFoundError: No module named 'onshapepy'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AguaClara/CEE4520/issues/51, or mute the thread https://github.com/notifications/unsubscribe-auth/AbN_635eoBOxZOhC3VAzA_B3O_mrbjpMks5vVZWSgaJpZM4bnk2k .

cheertsang commented 5 years ago

I upgraded aguaclara using sudo pip install, restarted Atom a couple times, but I am getting this error now: UserWarning: Specify a correct access key and secret key for the client


TypeError Traceback (most recent call last) /Users/cheertsang/anaconda/lib/python3.6/site-packages/onshapepy/core/onshape.py in init(self, stack, creds, logging) 49 try: ---> 50 self._access_key = creds['access_key'].encode('utf-8') 51 self._secret_key = creds['secret_key'].encode('utf-8')

TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

UserWarning Traceback (most recent call last)

in () ----> 1 import aguaclara.design.floc as floc /Users/cheertsang/anaconda/lib/python3.6/site-packages/aguaclara/design/floc.py in () 3 import aguaclara.core.constants as con 4 from aguaclara.core.units import unit_registry as u ----> 5 from onshapepy import Part 6 7 import math /Users/cheertsang/anaconda/lib/python3.6/site-packages/onshapepy/__init__.py in () ----> 1 from onshapepy.part import Part 2 from onshapepy.core.client import Client 3 from onshapepy.core.units import u /Users/cheertsang/anaconda/lib/python3.6/site-packages/onshapepy/part.py in () 3 ''' 4 ----> 5 from onshapepy.core.client import c 6 from onshapepy.core.utils import parse_quantity 7 import json /Users/cheertsang/anaconda/lib/python3.6/site-packages/onshapepy/core/client.py in () 430 431 # Start the default client. To change the client, just change this value. --> 432 c=Client() /Users/cheertsang/anaconda/lib/python3.6/site-packages/onshapepy/core/client.py in __init__(self, conf, conf_file) 63 64 self._stack = default_conf['stack'] ---> 65 self._api = Onshape(default_conf['stack'], default_conf['creds'], default_conf['logging']) 66 67 def update(self, conf): /Users/cheertsang/anaconda/lib/python3.6/site-packages/onshapepy/core/onshape.py in __init__(self, stack, creds, logging) 51 self._secret_key = creds['secret_key'].encode('utf-8') 52 except TypeError as e: ---> 53 raise UserWarning("Specify a correct access key and secret key for the client") 54 55 self._logging = logging UserWarning: Specify a correct access key and secret key for the client Any suggestions on how to fix this? Thank you!!
monroews commented 5 years ago

@ethan92429 @oliver-leung Apparently the code referencing onshape has been reinserted into the floc code and so now we get this same onshape error. I need this code to work because the assignment is due this week. Aargh. Can we either remove onshape or get onshape to work for all users?

oliver-leung commented 5 years ago

@ethan92429 Do you think it makes sense to make some sort of optional argument in the class constructor, so that people who have the Onshape keys specified can choose whether to use onshapepy?

monroews commented 5 years ago

Would it be possible to share the Onshape keys with my students?

Or could you check to see if an onshape key exists and only load the code that requires a key in that case?

The student assignment draft was supposed to be due tomorrow night. So a quick solution would be great!

oliver-leung commented 5 years ago

I've implemented a quick solution here.

monroews commented 5 years ago

floc.py is now working. Upgrade to aguaclara version 0.0.23. Do this by typing the following in the anaconda prompt or equivalent.

pip install aguaclara --upgrade