I’ve been able to successfully experiment with some complex Python code so I wanted to share some starter code so we can build useful community tools…
VB Setup
Imports Microsoft.VisualBasic
Imports System
Imports Tecan.Core.Scripting
Imports System.IO
Imports System.Collections
Imports System.Diagnostics
Public Class TestClass
Implements IScriptObject
Private Host As IScriptingHost
Public Property ScriptingHost() As IScriptingHost Implements IScriptObject.ScriptingHost
Get
Return Host
End Get
Set(ByVal value As IScriptingHost)
Host = value
End Set
End Property
Public Sub Execute() Implements IScriptObject.Execute
Dim pythonProcess As New Process()
Dim pythonProgram As New ProcessStartInfo()
pythonProgram.FileName = "C:\<REPLACE THIS WITH PATH TO>\Python39\python.exe" 'Default Python Installation
pythonProgram.Arguments = "C:\<REPLACE THIS WITH PATH TO>\TkinterDemo_v1.py"
pythonProcess.Start(pythonProgram)
End Sub
End Class
The Tkinter demo code is,
# Creates a simple Tkinter Message Box
from tkinter import messagebox
from tkinter import *
root = Tk()
root.withdraw()
messagebox.showinfo("Tecan Fluent Python", "Hello Lab Auto Forum!")
root.destroy()
Have you incorporated Python scripts into your workflow? How far down the rabbit hole have you gone?
6 Likes
Hello,
New Fluent learner here. This VB Script would be executed by FC, correct? What extra capabilities, if any, does this present over having FC Start Application a batch file which runs a Python script?
Appreciate your guidance!
1 Like
I don’t know anything about your company or it’s setup but biotech labs vary big time. I love the line, “if you’ve seen one lab, you’ve only seen one lab.” They vary drastically and that’s true with regard to quality, compliance and architecture. On security alone, I think some automation setups are going be in a for a rude awakening especially as the field continues to secure massive funding wins. With that said,
- It’s first and foremost an alternative to an EXE
- Minimizes need for expertise in VB
- Allows you to use any existing Python code base
- Some place have to register every EXE with software like CrowdStrike (imagine having to do this at scale for large biopharma and imagine having to document each one to ensure there’s not a security problem…)
- Some places won’t allow EXE’s to run period. Not even an option.
- Faster iterative process for development
- Because you can.
1 Like
I found a different way of doing the same kind of thing, although my method is a lot less clean.
I open a command prompt with /K in the start of my command line argument, then I can chain as many commands as I like after each other with “&” separating each line.
Pros:
No VB
Pretty flexible - everything you can do from a cmd you can do here, open specific python environment, run script etc
no EXEs
Cons:
Gets very messy very quickly!!
You can only get the error code, not the error message if you end with “& exit”
I thinks this could be a nice tool depending on the task and place, and its always nice to see how others would solve similar tasks
1 Like
That’s very clever!
I like to standardize my calls in subroutines because it’s good code practice but also because it allows me to narrow the scope for operators/other developers. Your version is way more versatile but potentially a security nightmare… would CrowdStrike block it?
With this simple code structure, I wrote an arg parser for my Slack Messaging that manages the white space problem in FC and pings specific scientists when their runs are complete.
I also connected my runs to Benchling so I could send over Metadata about my runs.
Next steps are total dB integration, preferably NoSQL but my start with SQL since they’re easy to spin up.
1 Like
Thanks,
I do not know what kind of security measures would block this - my guess is that it wouldn’t block it, but I don’t know.
I would like to know how to query a database through Fluent Control, the command line method doesn’t leave any good options for moving variables into Fluent Control - I have only just started making small VB.Net scripts to delete files and other simple tasks.
1 Like
I’m happy to share a quick template with the community.
Give me a few days to spin up something.
There are lots of things you can do in VB scripts including run sql statement. You can find many examples by searching online.
1 Like