Now we will run an analysis using the device data we uploaded in the previous notebook.
As before, make sure you have the following environment variables set or added to a .env file:
GDSFACTORY_HUB_API_URL="https://{org}.gdsfactoryhub.com"
GDSFACTORY_HUB_QUERY_URL="https://query.{org}.gdsfactoryhub.com"
GDSFACTORY_HUB_KEY="<your-gdsfactoryplus-api-key>"
import getpass
from tqdm.notebook import tqdm
import gdsfactoryhub as gfh
from gdsfactoryhub import FunctionTargetModel
project_id = f"cutback-{getpass.getuser()}"
client = gfh.create_client_from_env(project_id=project_id)
api = client.api()
query = client.query()
utils = client.utils()
You can either trigger analysis automatically by defining it in the design manifest, using the UI or using the Python DoData library.

{'output': {'component_loss': np.float64(0.10753299380599622),
'insertion_loss': np.float64(6.784093157796774)},
'summary_plot': <Figure size 640x480 with 0 Axes>,
'die_pkey': '66ab2c3a-f56e-407a-82e4-703ee367a2b1'}
<Figure size 640x480 with 0 Axes>
with gfh.suppress_api_error():
result = api.upload_function(
function_id="cutback_loss",
target_model="die",
file=gfh.get_module_path(cutback_loss),
test_target_model_pk=die_pks[0],
test_kwargs={},
)
Duplicate function
results = []
for die_pk in (pb := tqdm(die_pks)):
pb.set_postfix(die_pk=die_pk)
result = api.start_analysis(
analysis_id=f"die-cutback-{die_pk}",
function_id="cutback_loss",
target_model=FunctionTargetModel.DIE,
target_model_pk=die_pk,
kwargs={},
)
results.append(result)
0%| | 0/45 [00:00<?, ?it/s]
Let's have a look at the last analysis:
analysis_pks = [r["pk"] for r in results]
utils.analyses().wait_for_completion(pks=analysis_pks)
analyses = query.analyses().in_("pk", analysis_pks).execute().data
succesful_analyses = [a for a in analyses if a["status"] == "COMPLETED"]
analysis = succesful_analyses[-1]
img = api.download_plot(analysis["summary_plot"]["path"])
img.resize((530, 400))
Waiting for analyses: 0%| | 0/45 [00:00<?, ?it/s]
