Skip to content

Commit

Permalink
Merge pull request #104 from DataONEorg/feature-92-client-syntax
Browse files Browse the repository at this point in the history
Feature-92: HashStore Client Syntax
  • Loading branch information
doulikecookiedough authored Jun 4, 2024
2 parents 1874fb1 + 6b2f718 commit f28629f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,32 +262,35 @@ Client API Options:

How to use HashStore client (command line app)
```sh
# Step 0: Install hashstore via poetry to create an executable script
$ poetry install

# Step 1: Create a HashStore
$ python './src/hashstore/hashstoreclient.py' /path/to/store/ -chs -dp=3 -wp=2 -ap=SHA-256 -nsp="http://www.ns.test/v1"
$ hashstore /path/to/store/ -chs -dp=3 -wp=2 -ap=SHA-256 -nsp="http://www.ns.test/v1"

# Get the checksum of a data object
$ python './src/hashstore/hashstoreclient.py' /path/to/store/ -getchecksum -pid=persistent_identifier -algo=SHA-256
$ hashstore /path/to/store/ -getchecksum -pid=persistent_identifier -algo=SHA-256

# Find an object (returns the content identifier)
$ python './src/hashstore/hashstoreclient.py' /path/to/store/ -findobject -pid=persistent_identifier
$ hashstore /path/to/store/ -findobject -pid=persistent_identifier

# Store a data object
$ python './src/hashstore/hashstoreclient.py' /path/to/store/ -storeobject -pid=persistent_identifier -path=/path/to/object
$ hashstore /path/to/store/ -storeobject -pid=persistent_identifier -path=/path/to/object

# Store a metadata object
$ python './src/hashstore/hashstoreclient.py' /path/to/store/ -storemetadata -pid=persistent_identifier -path=/path/to/metadata/object -formatid=http://ns.dataone.org/service/types/v2.0
$ hashstore /path/to/store/ -storemetadata -pid=persistent_identifier -path=/path/to/metadata/object -formatid=http://ns.dataone.org/service/types/v2.0

# Retrieve a data object
$ python './src/hashstore/hashstoreclient.py' /path/to/store/ -retrieveobject -pid=persistent_identifier
$ hashstore /path/to/store/ -retrieveobject -pid=persistent_identifier

# Retrieve a metadata object
$ python './src/hashstore/hashstoreclient.py' /path/to/store/ -retrievemetadata -pid=persistent_identifier -formatid=http://ns.dataone.org/service/types/v2.0
$ hashstore /path/to/store/ -retrievemetadata -pid=persistent_identifier -formatid=http://ns.dataone.org/service/types/v2.0

# Delete a data object
$ python './src/hashstore/hashstoreclient.py' /path/to/store/ -deleteobject -pid=persistent_identifier
$ hashstore /path/to/store/ -deleteobject -pid=persistent_identifier

# Delete a metadata file
$ python './src/hashstore/hashstoreclient.py' /path/to/store/ -deletemetadata -pid=persistent_identifier -formatid=http://ns.dataone.org/service/types/v2.0
$ hashstore /path/to/store/ -deletemetadata -pid=persistent_identifier -formatid=http://ns.dataone.org/service/types/v2.0
```

## License
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "hashstore"
version = "1.1.0"
description = "HashStore, a hash-based object store for data packages."
authors = ["Matt Jones <gitcode@magisa.org>", "Dou Mok <douming.mok@gmail.com>"]
authors = ["Dou Mok <douming.mok@gmail.com>", "Matt Jones <gitcode@magisa.org>"]
readme = "README.md"

[tool.poetry.dependencies]
Expand All @@ -16,6 +16,9 @@ black = "^22.10.0"
pylint = "^2.17.4"
pg8000 = "^1.29.8"

[tool.poetry.scripts]
hashstore = "hashstore.hashstoreclient:main"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
3 changes: 2 additions & 1 deletion src/hashstore/hashstoreclient.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
"""HashStore Command Line App"""

import logging
Expand Down Expand Up @@ -255,7 +256,7 @@ def __init__(self, properties, testflag=None):
factory = HashStoreFactory()

# Get HashStore from factory
module_name = "filehashstore"
module_name = "hashstore.filehashstore"
class_name = "FileHashStore"

# Set multiprocessing to true
Expand Down

0 comments on commit f28629f

Please sign in to comment.