Пример #1
0
    def __testthis(self):
        for access_point in self.args:

            # Acces point not implemented yet for erddap
            # if access_point == 'profile':
            #     for arg in self.args['profile']:
            #         fetcher = ArgoIndexFetcher(src=self.src).profile(*arg).fetcher
            #         try:
            #             ds = fetcher.to_xarray()
            #             assert isinstance(ds, xr.Dataset)
            #         except ErddapServerError:
            #             # Test is passed even if something goes wrong with the erddap server
            #             pass
            #         except Exception:
            #             print("ERROR ERDDAP request:\n", fetcher.cname())
            #             pass

            if access_point == "float":
                for arg in self.args["float"]:
                    fetcher = ArgoIndexFetcher(src=self.src).float(arg).fetcher
                    ds = fetcher.to_xarray()
                    assert isinstance(ds, xr.Dataset)

            if access_point == "region":
                for arg in self.args["region"]:
                    fetcher = ArgoIndexFetcher(src=self.src).region(arg).fetcher
                    ds = fetcher.to_xarray()
                    assert isinstance(ds, xr.Dataset)
Пример #2
0
 def test_nocache(self):
     with argopy.set_options(cachedir="dummy", local_ftp=self.local_ftp):
         loader = ArgoIndexFetcher(src=self.src,
                                   cache=False).profile(2901623, 2)
         loader.to_xarray()
         with pytest.raises(FileSystemHasNoCache):
             loader.fetcher.cachepath
Пример #3
0
 def test_nocache(self):
     with tempfile.TemporaryDirectory() as testcachedir:
         with argopy.set_options(cachedir=testcachedir):
             loader = ArgoIndexFetcher(src=self.src, cache=False).float(self.requests['float'][0])
             loader.to_xarray()
             with pytest.raises(FileSystemHasNoCache):
                 loader.fetcher.cachepath
Пример #4
0
 def test_nocache(self):
     with argopy.set_options(cachedir=self.testcachedir):
         loader = ArgoIndexFetcher(src='erddap', cache=False).float(6902746)
         loader.to_xarray()
         with pytest.raises(FileSystemHasNoCache):
             loader.fetcher.cachepath
     shutil.rmtree(self.testcachedir)  # Make sure the cache is empty
Пример #5
0
def main(kind, args):
    """
    Build and run the download script for ARGO GDAC data
    """
    import argopy
    from argopy import IndexFetcher as ArgoIndexFetcher

    argopy.set_options(src="localftp", local_ftp=ARGO_localFTP)
    argopy.set_options(mode="expert")
    index_loader = ArgoIndexFetcher()

    if kind == "region":
        region = [
            float(args[0]),
            float(args[1]),
            float(args[2]),
            float(args[3]),
            *args[4:],
        ]
        print(region)
        argo_df = index_loader.region(region).to_dataframe()
    elif kind == "floats":
        argo_df = index_loader.float(args).to_dataframe()
    dl_list = build_dl(argo_df, ARGO_localFTP)
    print("Download commands built, launching subshell")
    launch_shell(dl_list)
    print("Done")
Пример #6
0
 def test_clearcache(self):
     with tempfile.TemporaryDirectory() as testcachedir:
         with argopy.set_options(cachedir=testcachedir):
             loader = ArgoIndexFetcher(src=self.src, cache=True).float(self.requests['float'][0])
             loader.to_xarray()
             loader.clear_cache()
             with pytest.raises(CacheFileNotFound):
                 loader.fetcher.cachepath
Пример #7
0
 def test_caching(self):
     with tempfile.TemporaryDirectory() as testcachedir:
         with argopy.set_options(cachedir=testcachedir):
             loader = ArgoIndexFetcher(src=self.src, cache=True).float(self.requests['float'][0])
             # 1st call to load and save to cache:
             loader.to_xarray()
             # 2nd call to load from cached file:
             ds = loader.to_xarray()
             assert isinstance(ds, xr.Dataset)
             assert isinstance(loader.fetcher.cachepath, str)
 def test_nocache(self):
     with tempfile.TemporaryDirectory() as testcachedir:
         with argopy.set_options(cachedir=testcachedir,
                                 local_ftp=self.local_ftp):
             loader = ArgoIndexFetcher(
                 src=self.src,
                 cache=False).profile(*self.requests['profile'][0])
             loader.to_dataframe()
             with pytest.raises(FileSystemHasNoCache):
                 loader.fetcher.cachepath
 def test_caching(self):
     with tempfile.TemporaryDirectory() as testcachedir:
         with argopy.set_options(cachedir=testcachedir,
                                 local_ftp=self.local_ftp):
             loader = ArgoIndexFetcher(src=self.src, cache=True).float(
                 self.requests['float'][0])
             # 1st call to load and save to cache:
             loader.to_dataframe()
             # 2nd call to load from cached file:
             df = loader.to_dataframe()
             assert isinstance(df, pd.core.frame.DataFrame)
             assert isinstance(loader.fetcher.cachepath, str)
Пример #10
0
 def test_caching_float(self):
     testcachedir = os.path.expanduser(os.path.join("~", ".argopytest_tmp"))
     with argopy.set_options(cachedir=testcachedir,
                             local_ftp=self.local_ftp):
         try:
             loader = ArgoIndexFetcher(src=self.src,
                                       cache=True).float(6901929)
             # 1st call to load from erddap and save to cachedir:
             ds = loader.to_xarray()
             # 2nd call to load from cached file:
             ds = loader.to_xarray()
             assert isinstance(ds, xr.Dataset)
             assert isinstance(loader.fetcher.cachepath, str)
             shutil.rmtree(testcachedir)
         except Exception:
             shutil.rmtree(testcachedir)
             raise
Пример #11
0
 def test_caching_index(self):
     with argopy.set_options(cachedir=self.testcachedir):
         try:
             loader = ArgoIndexFetcher(src='erddap',
                                       cache=True).float(6902746)
             # 1st call to load from erddap and save to cachedir:
             ds = loader.to_xarray()
             # 2nd call to load from cached file:
             ds = loader.to_xarray()
             assert isinstance(ds, xr.Dataset)
             assert isinstance(loader.fetcher.cachepath, str)
             shutil.rmtree(self.testcachedir)
         except ErddapServerError:  # Test is passed when something goes wrong because of the erddap server, not our fault !
             shutil.rmtree(self.testcachedir)
             pass
         except Exception:
             shutil.rmtree(self.testcachedir)
             raise
Пример #12
0
    def __testthis(self):
        for access_point in self.args:

            if access_point == "profile":
                for arg in self.args["profile"]:
                    with argopy.set_options(local_ftp=self.local_ftp):
                        fetcher = ArgoIndexFetcher(src=self.src).profile(
                            *arg).fetcher
                        df = fetcher.to_dataframe()
                        assert isinstance(df, pd.core.frame.DataFrame)

            if access_point == "float":
                for arg in self.args["float"]:
                    with argopy.set_options(local_ftp=self.local_ftp):
                        fetcher = ArgoIndexFetcher(
                            src=self.src).float(arg).fetcher
                        df = fetcher.to_dataframe()
                        assert isinstance(df, pd.core.frame.DataFrame)

            if access_point == "region":
                for arg in self.args["region"]:
                    with argopy.set_options(local_ftp=self.local_ftp):
                        fetcher = ArgoIndexFetcher(
                            src=self.src).region(arg).fetcher
                        df = fetcher.to_dataframe()
                        assert isinstance(df, pd.core.frame.DataFrame)
Пример #13
0
 def test_clearcache(self):
     with tempfile.TemporaryDirectory() as testcachedir:
         with argopy.set_options(cachedir=testcachedir,
                                 local_ftp=self.local_ftp):
             loader = ArgoIndexFetcher(
                 src=self.src,
                 cache=True).profile(*self.requests['profile'][0])
             loader.to_dataframe(
             )  # 1st call to load from source and save in memory
             loader.to_dataframe(
             )  # 2nd call to load from memory and save in cache
             loader.clear_cache()
             with pytest.raises(CacheFileNotFound):
                 loader.fetcher.cachepath
    def __testthis(self):
        for access_point in self.args:

            if access_point == "profile":
                for arg in self.args["profile"]:
                    with argopy.set_options(local_ftp=self.local_ftp):
                        fetcher = ArgoIndexFetcher(src=self.src).profile(*arg).fetcher
                        ds = fetcher.to_xarray()
                        assert isinstance(ds, xr.Dataset)

            if access_point == "float":
                for arg in self.args["float"]:
                    with argopy.set_options(local_ftp=self.local_ftp):
                        fetcher = ArgoIndexFetcher(src=self.src).float(arg).fetcher
                        ds = fetcher.to_xarray()
                        assert isinstance(ds, xr.Dataset)

            if access_point == "region":
                for arg in self.args["region"]:
                    with argopy.set_options(local_ftp=self.local_ftp):
                        fetcher = ArgoIndexFetcher(src=self.src).region(arg).fetcher
                        ds = fetcher.to_xarray()
                        assert isinstance(ds, xr.Dataset)
Пример #15
0
 def __test_region(self, bk, **ftc_opts):
     """ Test float index fetching for a given backend """
     for arg in self.args["region"]:
         options = {**self.fetcher_opts, **ftc_opts}
         f = ArgoIndexFetcher(src=bk, **options).region(arg)
         assert isinstance(f.to_xarray(), xr.Dataset)
Пример #16
0
 def __test_profile(self, bk, **ftc_opts):
     """ Test profile index fetching for a given backend """
     for arg in self.args["profile"]:
         options = {**self.fetcher_opts, **ftc_opts}
         f = ArgoIndexFetcher(src=bk, **options).profile(*arg)
         assert isinstance(f.to_xarray(), xr.Dataset)