Skip to content

study

Classes:

  • Study

    Represents an Antares study.

Functions:

Study

Study(name: str, version: str, services: StudyServices, path: PurePath = PurePath('.'))

Represents an Antares study.

This interface allows inspection and editing of study data, including study settings, areas, thermal clusters, hydro modeling, short-term storages, and generic binding constraints.

It also allows launching Antares simulations.

A study should not be created through its constructor. Please use one of the factory methods instead:

Methods:

Attributes:

Source code in src/antares/craft/model/study.py
def __init__(self, name: str, version: str, services: StudyServices, path: PurePath = PurePath(".")):
    self.name = name
    self.path = path
    self._study_service = services.study_service
    self._area_service = services.area_service
    self._link_service = services.link_service
    self._run_service = services.run_service
    self._binding_constraints_service = services.bc_service
    self._settings_service = services.settings_service
    self._xpansion_service = services.xpansion_service
    self._xpansion_configuration: XpansionConfiguration | None = None
    self._settings = StudySettings()
    self._areas: dict[str, Area] = {}
    self._links: dict[str, Link] = {}
    self._binding_constraints: dict[str, BindingConstraint] = {}
    self._outputs: dict[str, Output] = {}

    study_version = StudyVersion.parse(version)
    if study_version not in SUPPORTED_STUDY_VERSIONS:
        raise UnsupportedStudyVersion(version, SUPPORTED_STUDY_VERSIONS)
    self._version = study_version

has_an_xpansion_configuration property

has_an_xpansion_configuration: bool

Whether there is an xpansion configuration.

xpansion property

Xpansion configuration.

create_area

create_area(
    area_name: str,
    *,
    properties: Optional[AreaProperties] = None,
    ui: Optional[AreaUi] = None,
) -> Area

Adds a new area to the study.

Parameters:

  • area_name

    (str) –

    The name of the new area

  • properties

    (Optional[AreaProperties], default: None ) –

    Optional values for the properties of the area. If none are provided, the default values are used.

  • ui

    (Optional[AreaUi], default: None ) –

    Optional values for the UI properties of the area. If none are provided, the default values are used.

Returns:

  • Area

    The newly created area.

Source code in src/antares/craft/model/study.py
def create_area(
    self, area_name: str, *, properties: Optional[AreaProperties] = None, ui: Optional[AreaUi] = None
) -> Area:
    """Adds a new area to the study.

    Args:
        area_name: The name of the new area
        properties: Optional values for the properties of the area. If none are provided,
                    the default values are used.
        ui: Optional values for the UI properties of the area. If none are provided,
            the default values are used.

    Returns:
        The newly created area.
    """
    area = self._area_service.create_area(area_name, properties, ui)
    self._areas[area.id] = area
    return area

create_binding_constraint

create_binding_constraint(
    *,
    name: str,
    properties: Optional[BindingConstraintProperties] = None,
    terms: Optional[List[ConstraintTerm]] = None,
    less_term_matrix: Optional[DataFrame] = None,
    equal_term_matrix: Optional[DataFrame] = None,
    greater_term_matrix: Optional[DataFrame] = None,
) -> BindingConstraint

Create a new binding constraint.

Parameters:

  • name

    (str) –

    The name of the binding constraint.

  • properties

    (Optional[BindingConstraintProperties], default: None ) –

    Optional properties for the constraint.

  • terms

    (Optional[List[ConstraintTerm]], default: None ) –

    Optional list of terms for the constraint.

  • less_term_matrix

    (Optional[DataFrame], default: None ) –

    Optional less-than term matrix.

  • equal_term_matrix

    (Optional[DataFrame], default: None ) –

    Optional equality term matrix.

  • greater_term_matrix

    (Optional[DataFrame], default: None ) –

    Optional greater-than term matrix.

Returns:

Source code in src/antares/craft/model/study.py
def create_binding_constraint(
    self,
    *,
    name: str,
    properties: Optional[BindingConstraintProperties] = None,
    terms: Optional[List[ConstraintTerm]] = None,
    less_term_matrix: Optional[pd.DataFrame] = None,
    equal_term_matrix: Optional[pd.DataFrame] = None,
    greater_term_matrix: Optional[pd.DataFrame] = None,
) -> BindingConstraint:
    """Create a new binding constraint.

    Args:
        name: The name of the binding constraint.
        properties: Optional properties for the constraint.
        terms: Optional list of terms for the constraint.
        less_term_matrix: Optional less-than term matrix.
        equal_term_matrix: Optional equality term matrix.
        greater_term_matrix: Optional greater-than term matrix.

    Returns:
        The newly created binding constraint.
    """
    binding_constraint = self._binding_constraints_service.create_binding_constraint(
        name, properties, terms, less_term_matrix, equal_term_matrix, greater_term_matrix
    )
    self._binding_constraints[binding_constraint.id] = binding_constraint
    return binding_constraint
create_link(
    *,
    area_from: str,
    area_to: str,
    properties: Optional[LinkProperties] = None,
    ui: Optional[LinkUi] = None,
) -> Link

Adds a new link to the study.

Parameters:

  • area_from

    (str) –

    The id of the area from which the link starts

  • area_to

    (str) –

    The id of the area to which the link connects

  • properties

    (Optional[LinkProperties], default: None ) –

    Optional values for the properties of the link. If none are provided, the default values are used.

  • ui

    (Optional[LinkUi], default: None ) –

    Optional values for the UI properties of the link. If none are provided, the default values are used.

Returns:

  • Link

    The newly created link.

Source code in src/antares/craft/model/study.py
def create_link(
    self,
    *,
    area_from: str,
    area_to: str,
    properties: Optional[LinkProperties] = None,
    ui: Optional[LinkUi] = None,
) -> Link:
    """Adds a new link to the study.

    Args:
        area_from: The id of the area from which the link starts
        area_to: The id of the area to which the link connects
        properties: Optional values for the properties of the link. If none are provided,
                    the default values are used.
        ui: Optional values for the UI properties of the link. If none are provided,
            the default values are used.

    Returns:
        The newly created link.
    """

    temp_link = Link(area_from, area_to, link_service=cast(BaseLinkService, None))
    area_from, area_to = sorted([area_from, area_to])
    area_from_id = temp_link.area_from_id
    area_to_id = temp_link.area_to_id

    if area_from_id == area_to_id:
        raise LinkCreationError(area_from, area_to, "A link cannot start and end at the same area")

    missing_areas = [area for area in [area_from_id, area_to_id] if area not in self._areas]
    if missing_areas:
        raise LinkCreationError(area_from, area_to, f"{', '.join(missing_areas)} does not exist")

    if temp_link.id in self._links:
        raise LinkCreationError(area_from, area_to, f"A link from {area_from} to {area_to} already exists")

    link = self._link_service.create_link(area_from_id, area_to_id, properties, ui)
    self._links[link.id] = link
    return link

create_variant

create_variant(variant_name: str) -> Study

Creates a new variant for the study

Parameters:

  • variant_name

    (str) –

    the name of the new variant

Returns:

  • Study

    The variant in the form of a Study object

Source code in src/antares/craft/model/study.py
def create_variant(self, variant_name: str) -> "Study":
    """Creates a new variant for the study

    Args:
        variant_name: the name of the new variant

    Returns:
        The variant in the form of a `Study` object
    """
    return self._study_service.create_variant(variant_name)

create_xpansion_configuration

create_xpansion_configuration() -> XpansionConfiguration

Create an xpansion configuration.

Returns:

Source code in src/antares/craft/model/study.py
def create_xpansion_configuration(self) -> XpansionConfiguration:
    """Create an xpansion configuration.

    Returns:
        Default xpansion configuration.
    """
    if self.has_an_xpansion_configuration:
        raise XpansionConfigurationCreationError(
            self._study_service.study_id, "Xpansion configuration already exists"
        )

    configuration = self._xpansion_service.create_xpansion_configuration()
    self._xpansion_configuration = configuration
    return configuration

delete

delete(children: bool = False) -> None

Deletes this study.

Parameters:

  • children

    (bool, default: False ) –

    If True, also delete all children studies. That parameter only makes sense for variant studies on antares-web.

Source code in src/antares/craft/model/study.py
def delete(self, children: bool = False) -> None:
    """Deletes this study.

    Args:
        children: If True, also delete all children studies. That parameter only makes sense for
                  variant studies on antares-web.
    """
    self._study_service.delete(children)

delete_area

delete_area(area: Area) -> None

Deletes the specified area.

Parameters:

  • area

    (Area) –

    Name of the area.

Source code in src/antares/craft/model/study.py
def delete_area(self, area: Area) -> None:
    """Deletes the specified area.

    Args:
        area: Name of the area.
    """
    # Check area is not referenced in any binding constraint
    referencing_binding_constraints = []
    for bc in self._binding_constraints.values():
        for term in bc._terms.values():
            data = term.data
            if (isinstance(data, ClusterData) and data.area == area.id) or (
                isinstance(data, LinkData) and (data.area1 == area.id or data.area2 == area.id)
            ):
                referencing_binding_constraints.append(bc.name)
                break
    if referencing_binding_constraints:
        raise ReferencedObjectDeletionNotAllowed(area.id, referencing_binding_constraints, object_type="Area")

    # Delete the area
    self._area_service.delete_area(area.id, list(self._links.values()))
    self._areas.pop(area.id)
    # Delete it from the links
    links_to_remove = []
    for link_id, link in self._links.items():
        if link.area_from_id == area.id or link.area_to_id == area.id:
            links_to_remove.append(link_id)
    for link_id in links_to_remove:
        self._links.pop(link_id)

delete_binding_constraints

delete_binding_constraints(constraints: list[BindingConstraint]) -> None

Deletes the specified binding constraint.

Parameters:

Source code in src/antares/craft/model/study.py
def delete_binding_constraints(self, constraints: list[BindingConstraint]) -> None:
    """Deletes the specified binding constraint.

    Args:
        constraints: A list of binding constraints to delete.
    """
    self._study_service.delete_binding_constraints(constraints)
    for constraint in constraints:
        self._binding_constraints.pop(constraint.id)
delete_link(link: Link) -> None

Deletes the specified link.

Parameters:

  • link

    (Link) –

    The link object to delete.

Source code in src/antares/craft/model/study.py
def delete_link(self, link: Link) -> None:
    """Deletes the specified link.

    Args:
        link: The link object to delete.
    """
    # Check link is not referenced in any binding constraint
    referencing_binding_constraints = []
    for bc in self._binding_constraints.values():
        for term in bc._terms.values():
            data = term.data
            if isinstance(data, LinkData) and data.area1 == link.area_from_id and data.area2 == link.area_to_id:
                referencing_binding_constraints.append(bc.name)
                break
    if referencing_binding_constraints:
        raise ReferencedObjectDeletionNotAllowed(link.id, referencing_binding_constraints, object_type="Link")

    # Delete the link
    self._link_service.delete_link(link)
    self._links.pop(link.id)

delete_output

delete_output(output_name: str) -> None

Deletes the specified output.

Parameters:

  • output_name

    (str) –

    the name of the output to delete

Source code in src/antares/craft/model/study.py
def delete_output(self, output_name: str) -> None:
    """Deletes the specified output.

    Args:
        output_name: the name of the output to delete
    """
    self._study_service.delete_output(output_name)
    self._outputs.pop(output_name)

delete_outputs

delete_outputs() -> None

Deletes all simulation outputs.

Source code in src/antares/craft/model/study.py
def delete_outputs(self) -> None:
    """Deletes all simulation outputs."""
    self._study_service.delete_outputs()
    self._outputs.clear()

delete_xpansion_configuration

delete_xpansion_configuration() -> None

Delete current xpansion configuration.

Source code in src/antares/craft/model/study.py
def delete_xpansion_configuration(self) -> None:
    """Delete current xpansion configuration."""
    self._xpansion_service.delete()
    self._xpansion_configuration = None

generate_thermal_timeseries

generate_thermal_timeseries(nb_years: int) -> None

Generates timeseries for thermal clusters availability, based on timeseries generation parameters.

Parameters:

  • nb_years

    (int) –

    number of scenarios (years) to generate timeseries for.

Source code in src/antares/craft/model/study.py
def generate_thermal_timeseries(self, nb_years: int) -> None:
    """Generates timeseries for thermal clusters availability, based on timeseries generation parameters.

    Args:
        nb_years: number of scenarios (years) to generate timeseries for.
    """
    seed = self._settings.seed_parameters.seed_tsgen_thermal
    self._study_service.generate_thermal_timeseries(nb_years, self._areas, seed)
    # Copies objects to bypass the fact that the class is frozen
    self._settings.general_parameters = replace(self._settings.general_parameters, nb_timeseries_thermal=nb_years)

get_areas

get_areas() -> MappingProxyType[str, Area]

Retrieve a dictionary of the study areas.

Returns:

Source code in src/antares/craft/model/study.py
def get_areas(self) -> MappingProxyType[str, Area]:
    """Retrieve a dictionary of the study areas.

    Returns:
        A read-only mapping where keys are area names (str)
        and values are `Area` objects.
    """
    return MappingProxyType(dict(sorted(self._areas.items())))

get_binding_constraints

get_binding_constraints() -> MappingProxyType[str, BindingConstraint]

Retrieve a dictionary of the binding constraints.

Returns:

Source code in src/antares/craft/model/study.py
def get_binding_constraints(self) -> MappingProxyType[str, BindingConstraint]:
    """Retrieve a dictionary of the binding constraints.

    Returns:
        A read-only mapping where keys are binding constraints names (str)
        and values are `BindingConstraint` objects.
    """
    return MappingProxyType(self._binding_constraints)
get_links() -> MappingProxyType[str, Link]

Retrieve a dictionary of the study links.

Returns:

Source code in src/antares/craft/model/study.py
def get_links(self) -> MappingProxyType[str, Link]:
    """Retrieve a dictionary of the study links.

    Returns:
        A read-only mapping where keys are link names (str)
        and values are `Link` objects.
    """
    return MappingProxyType(self._links)

get_output

get_output(output_id: str) -> Output

Get a specific output

Parameters:

  • output_id

    (str) –

    ID of the output to get.

Returns:

  • Output

    Output with the output_id.

Raises:

Source code in src/antares/craft/model/study.py
def get_output(self, output_id: str) -> Output:
    """Get a specific output

    Args:
        output_id: ID of the output to get.

    Returns:
        Output with the output_id.

    Raises:
        KeyError: if it doesn't exist
    """
    return self._outputs[output_id]

get_outputs

get_outputs() -> MappingProxyType[str, Output]

Get outputs of current study.

Returns:

Source code in src/antares/craft/model/study.py
def get_outputs(self) -> MappingProxyType[str, Output]:
    """Get outputs of current study.

    Returns:
        Read-only proxy of the (output_id, Output) mapping.
    """
    return MappingProxyType(self._outputs)

get_scenario_builder

get_scenario_builder() -> ScenarioBuilder

Get scenario builder.

Returns:

  • ScenarioBuilder

    The current scenario builder used.

Source code in src/antares/craft/model/study.py
def get_scenario_builder(self) -> ScenarioBuilder:
    """Get scenario builder.

    Returns:
        The current scenario builder used.
    """
    sc_builder = self._study_service.get_scenario_builder(self._settings.general_parameters.nb_years, self._version)
    sc_builder.validate_against_version(self._version)
    sc_builder._set_study(self)
    return sc_builder

get_settings

get_settings() -> StudySettings

Retrieve the study settings.

Returns: Study settings.

Source code in src/antares/craft/model/study.py
def get_settings(self) -> StudySettings:
    """Retrieve the study settings.

    Returns: Study settings.
    """
    return self._settings

move

move(parent_path: Path) -> None

Moves the study to another directory.

Parameters:

  • parent_path

    (Path) –

    New path to move the study to.

Source code in src/antares/craft/model/study.py
def move(self, parent_path: Path) -> None:
    """Moves the study to another directory.

    Args:
        parent_path: New path to move the study to.
    """
    self.path = self._study_service.move_study(parent_path)

run_antares_simulation

run_antares_simulation(parameters: Optional[AntaresSimulationParameters] = None) -> Job

Runs the Antares simulation.

This method starts an antares simulation with the given parameters.

Parameters:

  • parameters

    (Optional[AntaresSimulationParameters], default: None ) –

    The simulation parameters (solver, number of CPU...).

Returns:

  • Job

    A job representing the simulation task.

Source code in src/antares/craft/model/study.py
def run_antares_simulation(self, parameters: Optional[AntaresSimulationParameters] = None) -> Job:
    """Runs the Antares simulation.

    This method starts an antares simulation with the given parameters.

    Args:
        parameters: The simulation parameters (solver, number of CPU...).

    Returns:
        A job representing the simulation task.
    """
    return self._run_service.run_antares_simulation(parameters)

set_playlist

set_playlist(playlist: dict[int, PlaylistParameters]) -> None

Set the playlist to give relative weights to each Monte Carlo year.

Parameters:

  • playlist

    (dict[int, PlaylistParameters]) –

    A mapping corresponding to the index of the MC year, and the PlaylistParameters that includes the weight of that year.

Source code in src/antares/craft/model/study.py
def set_playlist(self, playlist: dict[int, PlaylistParameters]) -> None:
    """Set the playlist to give relative weights to each Monte Carlo year.

    Args:
        playlist: A mapping corresponding to the index of the MC year,
            and the `PlaylistParameters` that includes the weight of that year.
    """
    self._settings_service.set_playlist(playlist)
    self._settings.playlist_parameters = playlist

set_scenario_builder

set_scenario_builder(scenario_builder: ScenarioBuilder) -> None

Set scenario builder.

Parameters:

  • scenario_builder

    (ScenarioBuilder) –

    The scenario builder to apply.

Source code in src/antares/craft/model/study.py
def set_scenario_builder(self, scenario_builder: ScenarioBuilder) -> None:
    """Set scenario builder.

    Args:
        scenario_builder: The scenario builder to apply.
    """
    scenario_builder.validate_against_version(self._version)
    self._study_service.set_scenario_builder(scenario_builder)

set_thematic_trimming

set_thematic_trimming(thematic_trimming: ThematicTrimmingParameters) -> None

Set a thematic trimming to select the outputs of the simulation.

Parameters:

Source code in src/antares/craft/model/study.py
def set_thematic_trimming(self, thematic_trimming: ThematicTrimmingParameters) -> None:
    """Set a thematic trimming to select the outputs of the simulation.

    Args:
        thematic_trimming: Selection of the outputs.
    """
    trimming = self._settings_service.set_thematic_trimming(thematic_trimming)
    self._settings.thematic_trimming_parameters = trimming

update_areas

update_areas(new_properties: Dict[Area, AreaPropertiesUpdate]) -> None

Update existing areas properties.

Parameters:

Source code in src/antares/craft/model/study.py
def update_areas(self, new_properties: Dict[Area, AreaPropertiesUpdate]) -> None:
    """Update existing areas properties.

    Args:
        new_properties: a mapping of the area to its new properties.
    """
    new_areas_props = self._area_service.update_areas_properties(new_properties)
    for area_prop in new_areas_props:
        self._areas[area_prop]._properties = new_areas_props[area_prop]

update_binding_constraints

update_binding_constraints(
    new_properties: Dict[str, BindingConstraintPropertiesUpdate],
) -> None

Update existing binding constraints.

Parameters:

Source code in src/antares/craft/model/study.py
def update_binding_constraints(self, new_properties: Dict[str, BindingConstraintPropertiesUpdate]) -> None:
    """Update existing binding constraints.

    Args:
        new_properties: a dictionary of binding constraint ID to binding constraint update data
    """
    new_bc_props = self._binding_constraints_service.update_binding_constraints_properties(new_properties)
    for bc_props in new_bc_props:
        self._binding_constraints[bc_props]._properties = new_bc_props[bc_props]
update_links(new_properties: Dict[str, LinkPropertiesUpdate]) -> None

Update existing links.

Parameters:

Source code in src/antares/craft/model/study.py
def update_links(self, new_properties: Dict[str, LinkPropertiesUpdate]) -> None:
    """Update existing links.

    Args:
        new_properties: A dictionary of link ID to link update data
    """
    new_links_props = self._link_service.update_links_properties(new_properties)
    for link_props in new_links_props:
        self._links[link_props]._properties = new_links_props[link_props]

update_renewable_clusters

update_renewable_clusters(
    new_properties: dict[RenewableCluster, RenewableClusterPropertiesUpdate],
) -> None

Update existing renewable cluster properties.

Parameters:

Source code in src/antares/craft/model/study.py
def update_renewable_clusters(
    self, new_properties: dict[RenewableCluster, RenewableClusterPropertiesUpdate]
) -> None:
    """Update existing renewable cluster properties.

    Args:
        new_properties: A dictionary of cluster to cluster update data.
    """
    new_renewable_clusters_props = self._area_service.renewable_service.update_renewable_clusters_properties(
        new_properties
    )
    for renewable in new_renewable_clusters_props:
        self._areas[renewable.area_id]._renewables[renewable.id]._properties = new_renewable_clusters_props[
            renewable
        ]

update_settings

update_settings(settings: StudySettingsUpdate) -> None

Updates the study settings.

Parameters:

  • settings

    (StudySettingsUpdate) –

    StudySettingsUpdate: New settings to be applied to the study configuration.

Source code in src/antares/craft/model/study.py
def update_settings(self, settings: StudySettingsUpdate) -> None:
    """Updates the study settings.

    Args:
        settings: StudySettingsUpdate: New settings to be applied to the study configuration.
    """
    new_settings = self._settings_service.edit_study_settings(settings, self._settings, self._version)
    self._settings = new_settings

update_st_storages

update_st_storages(new_properties: dict[STStorage, STStoragePropertiesUpdate]) -> None

Update existing short-term storage.

Parameters:

Source code in src/antares/craft/model/study.py
def update_st_storages(self, new_properties: dict[STStorage, STStoragePropertiesUpdate]) -> None:
    """Update existing short-term storage.

    Args:
        new_properties: a dictionary of short-term storage ID
            to short-term storage update data.
    """
    new_st_props = self._area_service.storage_service.update_st_storages_properties(new_properties)

    for storage in new_st_props:
        self._areas[storage.area_id]._st_storages[storage.id]._properties = new_st_props[storage]

update_st_storages_constraints

update_st_storages_constraints(
    new_constraints: dict[STStorage, dict[str, STStorageAdditionalConstraintUpdate]],
) -> None

Update existing short-term storage constraints.

Parameters:

Source code in src/antares/craft/model/study.py
def update_st_storages_constraints(
    self, new_constraints: dict[STStorage, dict[str, STStorageAdditionalConstraintUpdate]]
) -> None:
    """Update existing short-term storage constraints.

    Args:
        new_constraints: a dictionary of short-term storage objects
            to a dictionary of ST storage ID to some additional constraint update
            on the ST storage.
    """
    new_st_constraints = self._area_service.storage_service.update_st_storages_constraints(new_constraints)
    for area_id, value in new_st_constraints.items():
        for storage_id, values in value.items():
            for constraint_id, constraint in values.items():
                self._areas[area_id]._st_storages[storage_id]._constraints[constraint_id] = constraint

update_thermal_clusters

update_thermal_clusters(
    new_properties: dict[ThermalCluster, ThermalClusterPropertiesUpdate],
) -> None

Update existing thermal cluster properties.

Parameters:

Source code in src/antares/craft/model/study.py
def update_thermal_clusters(self, new_properties: dict[ThermalCluster, ThermalClusterPropertiesUpdate]) -> None:
    """Update existing thermal cluster properties.

    Args:
        new_properties: a dictionary of cluster to cluster update data.
    """
    new_thermal_clusters_props = self._area_service.thermal_service.update_thermal_clusters_properties(
        new_properties
    )
    for thermal in new_thermal_clusters_props:
        self._areas[thermal.area_id]._thermals[thermal.id]._properties = new_thermal_clusters_props[thermal]

wait_job_completion

wait_job_completion(job: Job, time_out: int = 172800) -> None

Waits for the completion of a job.

Parameters:

  • job

    (Job) –

    The job to wait for

  • time_out

    (int, default: 172800 ) –

    Time limit for waiting (seconds), default: 172800s

Raises:

  • SimulationTimeOutError

    if exceeded timeout

Source code in src/antares/craft/model/study.py
def wait_job_completion(self, job: Job, time_out: int = 172800) -> None:
    """
    Waits for the completion of a job.

    Args:
        job: The job to wait for
        time_out: Time limit for waiting (seconds), default: 172800s

    Raises:
        SimulationTimeOutError: if exceeded timeout
    """
    self._run_service.wait_job_completion(job, time_out)
    self._read_outputs()

create_study_api

create_study_api(
    study_name: str, version: str, api_config: APIconf, parent_path: Path | None = None
) -> Study

Creates a study on antares-web server.

Parameters:

  • study_name

    (str) –

    the name of the created study

  • version

    (str) –

    the study version, for example "8.8"

  • api_config

    (APIconf) –

    configuration to connect to antares-web server

  • parent_path

    (Path | None, default: None ) –

    an optional directory where the study will be stored in antares-web

Returns:

  • Study

    a Study object representing the newly created study

Source code in src/antares/craft/model/study.py
def create_study_api(study_name: str, version: str, api_config: APIconf, parent_path: Path | None = None) -> "Study":
    """
    Creates a study on antares-web server.

    Parameters:
        study_name: the name of the created study
        version: the study version, for example "8.8"
        api_config: configuration to connect to antares-web server
        parent_path: an optional directory where the study will be stored in antares-web

    Returns:
        a Study object representing the newly created study
    """
    from antares.craft.service.api_services.factory import create_study_api

    return create_study_api(study_name, version, api_config, parent_path)

create_study_local

create_study_local(
    study_name: str, version: str, parent_directory: Path | str
) -> Study

Creates a new study on your filesystem.

Parameters:

  • study_name

    (str) –

    the name of the created study

  • version

    (str) –

    the study version, for example "8.8"

  • parent_directory

    (Path | str) –

    the directory where the new study will be created

Returns:

  • Study

    a Study object representing the newly created study

Source code in src/antares/craft/model/study.py
def create_study_local(study_name: str, version: str, parent_directory: Path | str) -> "Study":
    """
    Creates a new study on your filesystem.

    Parameters:
        study_name: the name of the created study
        version: the study version, for example "8.8"
        parent_directory: the directory where the new study will be created

    Returns:
        a Study object representing the newly created study
    """
    from antares.craft.service.local_services.factory import create_study_local

    return create_study_local(study_name, version, parent_directory)

create_variant_api

create_variant_api(api_config: APIconf, study_id: str, variant_name: str) -> Study

Creates a new variant of an existing study, on antares-web server.

Parameters:

  • api_config

    (APIconf) –

    configuration to connect to antares-web server

  • study_id

    (str) –

    the ID of the base study on antares-web

  • variant_name

    (str) –

    the name of the newly created variant on antares-web

Returns:

  • Study

    a Study object representing the newly created variant on antares-web

Source code in src/antares/craft/model/study.py
def create_variant_api(api_config: APIconf, study_id: str, variant_name: str) -> "Study":
    """
    Creates a new variant of an existing study, on antares-web server.

    Parameters:
        api_config: configuration to connect to antares-web server
        study_id: the ID of the base study on antares-web
        variant_name: the name of the newly created variant on antares-web

    Returns:
        a Study object representing the newly created variant on antares-web
    """
    from antares.craft.service.api_services.factory import create_variant_api

    return create_variant_api(api_config, study_id, variant_name)

import_study_api

import_study_api(
    api_config: APIconf, study_path: Path, destination_path: Path | None = None
) -> Study

Creates a study on antares-web server, by importing an existing study archive from your filesystem.

Parameters:

  • api_config

    (APIconf) –

    configuration to connect to antares-web server

  • study_path

    (Path) –

    path to your study, either as a .zip or .7z file

  • destination_path

    (Path | None, default: None ) –

    an optional directory where the study will be stored in antares-web

Returns:

  • Study

    a Study object representing the newly created study

Source code in src/antares/craft/model/study.py
def import_study_api(api_config: APIconf, study_path: Path, destination_path: Path | None = None) -> "Study":
    """
    Creates a study on antares-web server, by importing an existing study archive from your filesystem.

    Parameters:
        api_config: configuration to connect to antares-web server
        study_path: path to your study, either as a .zip or .7z file
        destination_path: an optional directory where the study will be stored in antares-web

    Returns:
        a Study object representing the newly created study
    """
    from antares.craft.service.api_services.factory import import_study_api

    return import_study_api(api_config, study_path, destination_path)

read_outputs_api

read_outputs_api(api_config: APIconf, study_id: str) -> dict[str, Output]

Reads all outputs for a given study from antares-web server.

Why use this method instead of read_study_api: - It is more performant as it only retrieves output data - It allows you to read outputs for wrongly formatted studies or old studies prior to Simulator v8.8

Parameters:

  • api_config

    (APIconf) –

    configuration to connect to antares-web server

  • study_id

    (str) –

    the ID of the study on antares-web

Returns:

Source code in src/antares/craft/model/study.py
def read_outputs_api(api_config: APIconf, study_id: str) -> dict[str, Output]:
    """
    Reads all outputs for a given study from antares-web server.

    Why use this method instead of `read_study_api`:
    - It is more performant as it only retrieves output data
    - It allows you to read outputs for wrongly formatted studies or old studies prior to Simulator v8.8

    Parameters:
        api_config: configuration to connect to antares-web server
        study_id: the ID of the study on antares-web

    Returns:
        An (output_id, Output) mapping.
    """
    from antares.craft.service.api_services.factory import read_outputs_api

    return read_outputs_api(api_config, study_id)

read_outputs_local

read_outputs_local(study_path: Path | str) -> dict[str, Output]

Reads all outputs of an existing study on your filesystem.

Why use this method instead of read_study_local: - It is more performant as it only retrieves output data - It allows you to read outputs for wrongly formatted studies or old studies prior to Simulator v8.8

Parameters:

  • study_path

    (Path | str) –

    the path to the existing study on your filesystem

Returns:

Source code in src/antares/craft/model/study.py
def read_outputs_local(study_path: Path | str) -> dict[str, Output]:
    """
    Reads all outputs of an existing study on your filesystem.

    Why use this method instead of `read_study_local`:
    - It is more performant as it only retrieves output data
    - It allows you to read outputs for wrongly formatted studies or old studies prior to Simulator v8.8

    Parameters:
        study_path: the path to the existing study on your filesystem

    Returns:
        An (output_id, Output) mapping.
    """
    from antares.craft.service.local_services.factory import read_outputs_local

    return read_outputs_local(study_path)

read_study_api

read_study_api(api_config: APIconf, study_id: str) -> Study

Reads an existing study from antares-web server.

Parameters:

  • api_config

    (APIconf) –

    configuration to connect to antares-web server

  • study_id

    (str) –

    the ID of the study on antares-web

Returns:

  • Study

    a Study object representing the study on antares-web

Source code in src/antares/craft/model/study.py
def read_study_api(api_config: APIconf, study_id: str) -> "Study":
    """
    Reads an existing study from antares-web server.

    Parameters:
        api_config: configuration to connect to antares-web server
        study_id: the ID of the study on antares-web

    Returns:
        a Study object representing the study on antares-web
    """
    from antares.craft.service.api_services.factory import read_study_api

    return read_study_api(api_config, study_id)

read_study_local

read_study_local(study_path: Path | str) -> Study

Reads an existing study on your filesystem.

Parameters:

  • study_path

    (Path | str) –

    the path to the existing study on your filesystem

Returns:

  • Study

    a Study object representing the study on disk

Source code in src/antares/craft/model/study.py
def read_study_local(study_path: Path | str) -> "Study":
    """
    Reads an existing study on your filesystem.

    Parameters:
        study_path: the path to the existing study on your filesystem

    Returns:
        a Study object representing the study on disk
    """
    from antares.craft.service.local_services.factory import read_study_local

    return read_study_local(study_path)