Ivory Zhang (9a9d1421) at 18 Mar 03:37
update requirements.txt, add flask[async]
i didnt think about testing that, sounds good! yeah right now if there is an additional dynamic parameter added the workflow that gets used just disappears from the design
Veronica Lai (60d1920a) at 17 Mar 16:58
Veronica Lai (e7c735a2) at 17 Mar 16:58
Merge branch '90-always-show-current-iteration-out-of-total-number-...
... and 2 more commits
Closes #90
Veronica Lai (60d1920a) at 17 Mar 16:57
fix displaying iteration in logging panel if move away then back to...
... and 7 more commits
Veronica Lai (3f154192) at 17 Mar 16:56
bug with generated proxy py files, that calls will raise an AuthenticationError but no such error exists/is imported
def _call(self, payload):
"""Make API call with error handling."""
res = session.post(self.url, json=payload, allow_redirects=False)
# Handle 302 redirect (likely auth issue)
if res.status_code == 302:
try:
self._auth()
res = session.post(self.url, json=payload, allow_redirects=False)
except Exception as e:
raise AuthenticationError(
"Authentication failed during re-attempt. "
"Please check your credentials or connection."
) from e
res.raise_for_status()
data = res.json()
if not data.get('success'):
raise Exception(data.get('output', "Unknown API error."))
return data.get('output')
but it doesnt seem like the code will get to that issue because in the call to _auth() usually if the username or password is incorrect it will raise the regular Exception there
def _auth(self):
username = self.username or 'admin'
password = self.password or 'admin'
res = session.get('http://192.168.30.251:8000/ivoryos/', allow_redirects=False)
if res.status_code == 200:
return
else:
session.post(
'http://192.168.30.251:8000/ivoryos/auth/login',
data={"username": username, "password": password}
)
res = session.get('http://192.168.30.251:8000/ivoryos/', allow_redirects=False)
if res.status_code != 200:
raise Exception("Authentication failed")
Closes #95
Veronica Lai (83285318) at 17 Mar 16:56
Merge branch '95-bug-generated-proxy-authentication-error' into 'main'
... and 1 more commit
Veronica Lai (3f154192) at 17 Mar 16:54
replace unknown AuthenticationError with Exception when generate cl...
... and 4 more commits
Veronica Lai (4e8ca788) at 17 Mar 16:53
example with `community/examples/abstract_sdl_example/abstract_sdl.py`
if in your script there is an import from another file and it is an enum that gets imported imported, then the enum will be duplicated in the generated proxy script but in the method it still tries to use the path, but the module that the import comes from never gets imported.
second if a method argument has a default enum value, it is not in correct python.
for both issues see below for more details
example. move the Solvent enum to a different module and import it into abstract_sdl.py and update the dose_solvent method to:
# @prefect.task
def dose_solvent(self,
solvent_name: Solvent = Solvent.Methanol,
amount_in_ml: float = 5,
rate_ml_per_minute: float = 1
):
print("dosing liquid")
...
and this is what the generated proxy looks like. in this case 2 errors:
community when it is not imported (and not needed) solvent_name: community.solvent.Solvent . instead if should use just the Solvent that is recreated at the top of the script. so it should be solvent_name: Solvent
<> for the default solvent_name when it is invalid python. so <Solvent.Methanol: 'Methanol'> should be Solvent.Methanol insteadimport requests
from typing import List, Optional
session = requests.Session()
# Generated Enum definitions
from enum import Enum
class Solvent(Enum):
Methanol = "Methanol"
Ethanol = "Ethanol"
Acetone = "Acetone"
DMF = "dmf"
...
class Sdl:
"""Auto-generated API client for sdl operations."""
url = "http://127.0.0.1:8000/ivoryos/instruments/deck.sdl"
...
def dose_solvent(self, solvent_name: Optional[community.solvent.Solvent] = <Solvent.Methanol: 'Methanol'>, amount_in_ml: float = 5, rate_ml_per_minute: float = 1):
payload = {"hidden_name": "dose_solvent"}
payload["solvent_name"] = solvent_name
payload["amount_in_ml"] = amount_in_ml
payload["rate_ml_per_minute"] = rate_ml_per_minute
return self._call(payload)
Veronica Lai (ec440305) at 17 Mar 16:53
Merge branch '94-generate-proxy-import-classes-error' into 'main'
... and 3 more commits
Closes #94
Closes #90
Closes #95
Closes #94
we might have to edit the nested workflow at the drag-n-drop layer, and let the runner take the script directly. one issue was when there is additional dynamic params, the nested workflow won't update the params. We can discuss this later!