openEDI / oedisi-example

Minimum working example for oedisi API
BSD 3-Clause "New" or "Revised" License
7 stars 0 forks source link

Add check for existing file so it will default to downloading only if the file doesn't exist. #75

Open Tylores opened 6 months ago

Tylores commented 6 months ago
        if config.existing_feeder_file is None:
            if self._use_smartds:
                self._feeder_file = os.path.join("opendss", "Master.dss")
                self.download_data("oedi-data-lake", update_loadshape_location=True)
            elif not self._use_smartds and not self._user_uploads_model:
                self._feeder_file = os.path.join("opendss", "master.dss")
                self.download_data("gadal")
            else:
                # User should have uploaded model using endpoint
                raise Exception("Set existing_feeder_file when uploading data")
        else:
            self._feeder_file = config.existing_feeder_file
josephmckinsey commented 6 months ago

If I'm understanding the suggestion, it would be something like if not _feeder_file.exists(): self.download_data(...)?

Tylores commented 6 months ago

This is what I used to do and what was going to add the the issue, but got side tracked.

        if config.existing_feeder_file is None:
            if self._use_smartds:
                self._feeder_file = os.path.join("opendss", "Master.dss")
                self.download_data(
                    "oedi-data-lake", update_loadshape_location=True)
            else:
                self._feeder_file = os.path.join("opendss", "master.dss")
                self.download_data("gadal")
        elif not os.path.exists(config.existing_feeder_file):
            if self._use_smartds:
                self._feeder_file = os.path.join("opendss", "Master.dss")
                self.download_data(
                    "oedi-data-lake", update_loadshape_location=True)
            else:
                self._feeder_file = os.path.join("opendss", "master.dss")
                self.download_data("gadal")
        else:
            self._feeder_file = config.existing_feeder_file
josephmckinsey commented 6 months ago

Ah, so existing_feeder_file would be more like feeder_file_cache?

Tylores commented 6 months ago

Yeah that way you can set the existing file and not have it throw and error if it doesn't exist the first time.

On Tue, Mar 26, 2024, 3:11 PM Joseph McKinsey @.***> wrote:

Ah, so existing_feeder_file would be more like feeder_file_cache?

— Reply to this email directly, view it on GitHub https://github.com/openEDI/oedisi-example/issues/75#issuecomment-2021557833, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE6NDIVLGJNBFT7ESIGKYK3Y2HXB3AVCNFSM6AAAAABFJMECD6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRRGU2TOOBTGM . You are receiving this because you authored the thread.Message ID: @.***>