Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add DOWNLOAD staging action #3282

Merged
merged 8 commits into from
Dec 16, 2024
Merged

add DOWNLOAD staging action #3282

merged 8 commits into from
Dec 16, 2024

Conversation

andre-merzky
Copy link
Member

This fixes #3266

Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 28.57143% with 20 lines in your changes missing coverage. Please review.

Project coverage is 42.91%. Comparing base (2618c57) to head (6942125).
Report is 9 commits behind head on devel.

Files with missing lines Patch % Lines
src/radical/pilot/utils/staging_helper.py 33.33% 12 Missing ⚠️
src/radical/pilot/agent/staging_input/default.py 14.28% 6 Missing ⚠️
src/radical/pilot/agent/staging_output/default.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3282      +/-   ##
==========================================
+ Coverage   42.78%   42.91%   +0.12%     
==========================================
  Files          97       97              
  Lines       11310    11286      -24     
==========================================
+ Hits         4839     4843       +4     
+ Misses       6471     6443      -28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@AymenFJA AymenFJA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left 2 comments @andre-merzky. Thanks.

def download(self, src, tgt, flags):
tgt = ru.Url(tgt).path
self.mkdir(os.path.dirname(tgt), flags)
ru.sh_callout('wget -r %s -O %s' % (src, tgt))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I am mistaken, but some Linux flavors might not have the wget command. So to avoid this, I think Python approach is the most guaranteed to work in most cases as Python interpreter must exist. So I would suggest to do the following:

import requests 

def download(self, src: str, tgt: str, flags:str) -> None:
    """Download the remote file to the current tgt directory."""
    response = requests.get(src, stream=True)

    tgt = ru.Url(tgt).path

    try:
       response.raise_for_status()  # Check if the download was successful
    except Exception as e:
       print(f'ERROR: skipping staging, download failed due to: {e}')
       return
   
    self.mkdir(os.path.dirname(tgt), flags)

    # Save the file content
    with open(tgt, 'wb') as f:
        for chunk in response.iter_content(chunk_size=8192):
            f.write(chunk)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, we can use python for that, will change!

examples/05_task_input_data.py Show resolved Hide resolved
Copy link
Contributor

@AymenFJA AymenFJA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @andre-merzky

@andre-merzky andre-merzky merged commit 6e61f45 into devel Dec 16, 2024
30 checks passed
@andre-merzky andre-merzky deleted the feature/download branch December 16, 2024 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Download input staging
2 participants