digitalearthpacific / dep-tools

Processing tools for Digital Earth Pacific
MIT License
1 stars 0 forks source link

Need a way to specific local "root" directory for writer #7

Closed alexgleith closed 11 months ago

alexgleith commented 12 months ago

Currently the writer works for relative paths, but it would be good if we can specify /tmp/ or ./data as the "root" directory for output files when running end-to-end testing locally.

jessjaco commented 11 months ago

I know I need to do some documentation, but can't you use dep_tools.namers.LocalPath and pass the absolute path via local_folder on initiation?

alexgleith commented 11 months ago

I think I tried that and it didn't work. But yeah, it looks like you should be able to do that!

jessjaco commented 11 months ago

Ok, I'll test when I get a chance

On Fri, Sep 15, 2023 at 3:04 PM Alex Leith @.***> wrote:

I think I tried that and it didn't work. But yeah, it looks like you should be able to do that!

— Reply to this email directly, view it on GitHub https://github.com/digitalearthpacific/dep-tools/issues/7#issuecomment-1721913378, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJRLBM4HEA7CJ3EGI6AYVLX2TGHFANCNFSM6AAAAAA4VPR4JA . You are receiving this because you commented.Message ID: @.***>

alexgleith commented 11 months ago

Testing now, and it doesn't work:

from dep_tools.namers import LocalPath

# Write out files
dep_path = LocalPath("s2", "mangroves", "0.0.0", datetime, local_folder="data")
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[/Users/alex/git/digitalearthpacific/dep-mangroves/Test_Mangroves.ipynb](https://file+.vscode-resource.vscode-cdn.net/Users/alex/git/digitalearthpacific/dep-mangroves/Test_Mangroves.ipynb) Cell 8 line 4
      [1](vscode-notebook-cell:/Users/alex/git/digitalearthpacific/dep-mangroves/Test_Mangroves.ipynb#X11sZmlsZQ%3D%3D?line=0) from dep_tools.namers import LocalPath
      [3](vscode-notebook-cell:/Users/alex/git/digitalearthpacific/dep-mangroves/Test_Mangroves.ipynb#X11sZmlsZQ%3D%3D?line=2) # Write out files
----> [4](vscode-notebook-cell:/Users/alex/git/digitalearthpacific/dep-mangroves/Test_Mangroves.ipynb#X11sZmlsZQ%3D%3D?line=3) dep_path = LocalPath("s2", "mangroves", "0.0.0", datetime, local_folder="data")
      [6](vscode-notebook-cell:/Users/alex/git/digitalearthpacific/dep-mangroves/Test_Mangroves.ipynb#X11sZmlsZQ%3D%3D?line=5) writer = LocalDsWriter(itempath=dep_path)
      [7](vscode-notebook-cell:/Users/alex/git/digitalearthpacific/dep-mangroves/Test_Mangroves.ipynb#X11sZmlsZQ%3D%3D?line=6) out_files = writer.write(output_data, item_id)

TypeError: LocalPath.__init__() got multiple values for argument 'local_folder'
alexgleith commented 11 months ago

Ok, it does work if you use it like this:

dep_path = LocalPath(local_folder="data", sensor="s2", dataset_id="mangroves", version="0.0.0", time=datetime)

Which is a bit of a confusing API... but ok :-)

alexgleith commented 11 months ago

And using this it writes asset URLs out wrong...

"href": "https:/deppcpublicstorage.blob.core.windows.net/output/data/dep_s2_mangroves_PG_051_2023_ndvi.tif",

This should really now be a relative path to the STAC doc if it's writing local files.

alexgleith commented 11 months ago

Ok, it's fine, but this code is wrong for local writing: https://github.com/digitalearthpacific/dep-tools/blob/main/dep_tools/writers.py#L67

alexgleith commented 11 months ago

Closing this issue, as it works, even if it's a bit clumsy.