Github gist/url or file drop as Automate input?

Hey guys, maple here

We were brainstorming about how to make it easier to load test specs to run in automate against a model.

At the moment, when someone wants to create their own specs and run them against a model they have to clone the Maple-ci repo write there their own test specs there and deploy that as its own Speckle automation function.

That means for every model we would need one automate function. But what we would like is to have one automate function which allows user’s to load their test specs file.

One possible option we thought is letting the user pass inside the function parameter a url to a GitHub repo (or Gist) containing a ‘spec.py’ file (or a drag an drop of the file itself would be great). Then automate function we create would take care of reading that module and running each one of the specs inside of it.

After a quick research we thought this could be done with the http-import package and a decorator on the spec function, for example. We would be keen on hearing your thoughts :slight_smile:

Thinking more broadly, the example rule-checking automation journey I took workshop attendees through at BILT externalised rules along a similar thought process.

In that case rules were defined in a Google Spreadsheet as an input and the URL to that sheet was a FunctionInput.

The row-based rules were then interpreted into testing rules at runtime.

eg.

I’m itching to see what a next iteration might look like using Maple tbh.

2 Likes

That’s a really cool that we were then thinking the same idea of externalising the rules and reading them at runtime. Thank you for sharing

We solved reading a file from the url file using the library httpimport:

from inspect import getmembers, isfunction
import httpimport
import maple as mp

url = "https://gist.githubusercontent.com/andrsbtrg/1c6ebcfca23492b2dd899b43817ea88a/raw/4183c73c61816a36f0cfe0fc51ef0e2459aaf253"
with httpimport.remote_repo(url):
    import specs

funcs = [func[1] for func in getmembers(specs, isfunction)] # ugly one liner to get every function from a module

mp.run(*funcs)

it still needs some work on the edges but we’re getting there and we will be sharing what’s next

2 Likes