Skip to content

Commit

Permalink
Merge pull request #13 from vvarg229/fix-attr
Browse files Browse the repository at this point in the history
Fix #12
  • Loading branch information
roman-khimov authored Nov 14, 2023
2 parents f0408dc + 2817593 commit 5987182
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@ jobs:
source venv/bin/activate && pytest test_downloads.py --base_url="$OUTPUT_CONTAINER_URL"
working-directory: ./tests

- name: Run gh-push-to-neofs without attributes
id: gh_push_to_neofs_without_attributes
uses: ./
with:
NEOFS_WALLET: ${{ secrets.NEOFS_WALLET }}
NEOFS_WALLET_PASSWORD: ${{ secrets.NEOFS_WALLET_PASSWORD }}
NEOFS_NETWORK_DOMAIN: ${{ vars.NEOFS_NETWORK_DOMAIN }}
NEOFS_HTTP_GATE: ${{ vars.NEOFS_HTTP_GATE }}
STORE_OBJECTS_CID: ${{ vars.STORE_OBJECTS_CID }}
LIFETIME: ${{ vars.LIFETIME }}
PATH_TO_FILES_DIR: ${{ env.TESTS_DATA_DIR }}
URL_PREFIX: ${{ env.URL_PREFIX }}

- name: Run tests
env:
OUTPUT_CONTAINER_URL: ${{ steps.gh_push_to_neofs_with_url_prefix.outputs.OUTPUT_CONTAINER_URL }}
run: |
source venv/bin/activate && pytest test_downloads.py --base_url="$OUTPUT_CONTAINER_URL"
working-directory: ./tests

- name: Prepare directory name for tests without url prefix
shell: bash
env:
Expand Down
10 changes: 8 additions & 2 deletions push-to-neofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def parse_args():
"For example, it's convenient to create url links to access an object via http:"
"FilePath=96-1697035975/dir/3.txt"
"Type=test_result,Master=true,RUN_ID=96-1697035975",
nargs="?",
const=None,
default=None,
)
parser.add_argument(
Expand All @@ -39,6 +41,8 @@ def parse_args():
" https://http.fs.neo.org/HXSaMJXk2g8C14ht8HSi7BBaiYZ1HeWh2xnWPGQCg4H6/832-1695916423/file.txt"
"Without --url_path_prefix the url will be:"
" https://http.fs.neo.org/HXSaMJXk2g8C14ht8HSi7BBaiYZ1HeWh2xnWPGQCg4H6/file.txt",
nargs="?",
const=None,
default=None,
)
parser.add_argument(
Expand All @@ -54,6 +58,8 @@ def parse_args():
help="Lifetime in epochs - number of epochs for object to stay valid. If provided, will be added to the "
"current epoch to calculate expiration epoch. If not provided, or if it is 0, the report will be stored "
"indefinitely",
nargs="?",
const=None,
default=None,
)
parser.add_argument(
Expand Down Expand Up @@ -95,14 +101,14 @@ def push_file(
mime_type = magic.from_file(filepath, mime=True)
relative_path = os.path.relpath(filepath, os.path.dirname(directory))

if url_path_prefix is not None:
if url_path_prefix is not None and url_path_prefix != "":
neofs_path_attr = os.path.join(url_path_prefix, relative_path)
else:
neofs_path_attr = relative_path

base_cmd_with_file = f"{base_cmd} --file {filepath} --attributes {FILE_PATH}={neofs_path_attr},{CONTENT_TYPE}={mime_type}"

if attributes is not None:
if attributes is not None and attributes != "":
base_cmd_with_file += f",{attributes}"

print(f"Neofs cli cmd is: {base_cmd_with_file}")
Expand Down

0 comments on commit 5987182

Please sign in to comment.