Repository: Lightning-AI/pytorch-lightning
File: pytorch_lightning/loggers/neptune.py (Python)

Code before:
            They are editable after the experiment is created.
            Properties are displayed in the experiment’s Details section and
            each key-value pair can be viewed in the experiments view as a column.
        tags: Optional. Default is ``[]``. Must be list of str. Tags of the experiment.
            They are editable after the experiment is created (see: ``append_tag()`` and ``remove_tag()``).
            Tags are displayed in the experiment’s Details section and can be viewed
            in the experiments view as a column.
    """

    def __init__(self,
                 api_key: Optional[str] = None,
                 project_name: Optional[str] = None,
                 close_after_fit: Optional[bool] = True,
                 offline_mode: bool = False,
                 experiment_name: Optional[str] = None,
                 upload_source_files: Optional[List[str]] = None,
                 params: Optional[Dict[str, Any]] = None,
                 properties: Optional[Dict[str, Any]] = None,
                 tags: Optional[List[str]] = None,
                 **kwargs):
        if not _NEPTUNE_AVAILABLE:
            raise ImportError('You want to use `neptune` logger which is not installed yet,'
                              ' install it with `pip install neptune-client`.')
        super().__init__()
        self.api_key = api_key
        self.project_name = project_name
        self.offline_mode = offline_mode
        self.close_after_fit = close_after_fit
        self.experiment_name = experiment_name
        self.upload_source_files = upload_source_files
        self.params = params
        self.properties = properties
        self.tags = tags
        self._kwargs = kwargs
        self._experiment_id = None
        self._experiment = None

        log.info(f'NeptuneLogger will work in {"offline" if self.offline_mode else "online"} mode')

    def __getstate__(self):
        state = self.__dict__.copy()

        # Experiment cannot be pickled, and additionally its ID cannot be pickled in offline mode
        state['_experiment'] = None
        if self.offline_mode:
            state['_experiment_id'] = None

        return state

    @property
    @rank_zero_experiment

Review comment (suggestion):
```suggestion
        self._experiment = self.experiment
```
try this, this will only run on rank 0

Code after:
    LOGGER_JOIN_CHAR = '-'

    def __init__(
        self,
        api_key: Optional[str] = None,
        project_name: Optional[str] = None,
        close_after_fit: Optional[bool] = True,
        offline_mode: bool = False,
        experiment_name: Optional[str] = None,
        experiment_id: Optional[str] = None,
        prefix: str = '',
        **kwargs
    ):
        if neptune is None:
            raise ImportError('You want to use `neptune` logger which is not installed yet,'
                              ' install it with `pip install neptune-client`.')
        super().__init__()
        self.api_key = api_key
        self.project_name = project_name
        self.offline_mode = offline_mode
        self.close_after_fit = close_after_fit
        self.experiment_name = experiment_name
        self._prefix = prefix
        self._kwargs = kwargs
        self.experiment_id = experiment_id
        self._experiment = None

        log.info(f'NeptuneLogger will work in {"offline" if self.offline_mode else "online"} mode')

    def __getstate__(self):
        state = self.__dict__.copy()

        # Experiment cannot be pickled, and additionally its ID cannot be pickled in offline mode
        state['_experiment'] = None
        if self.offline_mode:
            state['experiment_id'] = None

        return state

    @property
    @rank_zero_experiment
    def experiment(self) -> Experiment:
        r"""
        Actual Neptune object. To use neptune features in your
        :class:`~pytorch_lightning.core.lightning.LightningModule` do the following.

        Example::

            self.logger.experiment.some_neptune_function()

        """