.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/00-model_configuration_reuse.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__examples_00-model_configuration_reuse.py: .. _ref_model_configuration_reuse: Model configuration reuse ========================= This example demonstrates how to retrieve the latest model configuration of a project and use it to launch a model build in another project. .. GENERATED FROM PYTHON SOURCE LINES 12-14 Import necessary libraries -------------------------- .. GENERATED FROM PYTHON SOURCE LINES 14-19 .. code-block:: Python import ansys.simai.core as asc simai = asc.from_config() .. GENERATED FROM PYTHON SOURCE LINES 20-23 Create a project and allocate training data ------------------------------------------- Define the project name. .. GENERATED FROM PYTHON SOURCE LINES 23-25 .. code-block:: Python new_project_name = "new-project" .. GENERATED FROM PYTHON SOURCE LINES 26-27 Create the project. .. GENERATED FROM PYTHON SOURCE LINES 27-29 .. code-block:: Python new_project = simai.projects.create(new_project_name) .. GENERATED FROM PYTHON SOURCE LINES 30-31 Set the names of the data samples to be associated with the created project. .. GENERATED FROM PYTHON SOURCE LINES 31-38 .. code-block:: Python training_samples_name = [ "TrainingData_001", "TrainingData_002", "TrainingData_003", "TrainingData_004", ] .. GENERATED FROM PYTHON SOURCE LINES 39-41 Retrieve the desired training data samples and associate them with the new project. .. GENERATED FROM PYTHON SOURCE LINES 41-46 .. code-block:: Python for td_name in training_samples_name: filt = {"name": td_name} td = simai.training_data.list(filters=filt) td[0].add_to_project(new_project) .. GENERATED FROM PYTHON SOURCE LINES 47-50 Select a model configuration and associate it with the newly created project ---------------------------------------------------------------------------- Retrieve the model configuration from another project that you wish to reuse. .. GENERATED FROM PYTHON SOURCE LINES 50-55 .. code-block:: Python old_project = "old-ps" my_project = simai.projects.get(name=old_project) last_build_config = my_project.last_model_configuration .. GENERATED FROM PYTHON SOURCE LINES 56-58 If the new project meets the requirements for training, associate the project's ID with the configuration and launch a model build. .. GENERATED FROM PYTHON SOURCE LINES 58-65 .. code-block:: Python if new_project.is_trainable(): # Assign the new project's ID to the configuration to transfer the # configuration from the old project to the new one last_build_config.project_id = new_project.id # Launch a model build for the new project new_model = simai.models.build(last_build_config) .. _sphx_glr_download__examples_00-model_configuration_reuse.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 00-model_configuration_reuse.ipynb <00-model_configuration_reuse.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 00-model_configuration_reuse.py <00-model_configuration_reuse.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 00-model_configuration_reuse.zip <00-model_configuration_reuse.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_