Here is a quick tutorial on how to copy Data from S3 to a public storage. In this tutorial, we will scrape all the links from a public AWS S3 buckets and then copy the data to IPFS using Bacalhau.
Prerequisite
To get started, you need to install the Bacalhau client, see more information here
-i "s3://noaa-goes16/ABI-L1b-RadC/2000/001/12/OR_ABI-L1b-RadC-M3C01*:/inputs,opt=region=us-east-1: defines S3 objects as inputs to the job. In this case, it will download all objects that match the prefix ABI-L1b-RadC/2000/001/12/OR_ABI-L1b-RadC-M3C01 from the bucket noaa-goes16 in us-east-1 region, and mount the objects under /inputs path inside the docker job.
-- sh -c "cp -r /inputs/* /outputs/": copies all files under /inputs to /outputs, which is by default the result output directory which all of its content will be published to the specified destination, which is IPFS by default
When a job is submitted, Bacalhau prints out the related job_id. We store that in an environment variable so that we can reuse it later on.
:::tip This only works with datasets that are publicly accessible and don't require an AWS account or pay to use buckets. :::
Checking the State of your Jobs
Job status: You can check the status of the job using bacalhau list.
%%bashbacalhaulist--id-filter ${JOB_ID} --wide
When it says Published or Completed, that means the job is done, and we can get the results.
Job information: You can find out more information about your job by using bacalhau describe.
%%bashbacalhaudescribe ${JOB_ID}
Job download: You can download your job results directly by using bacalhau get. Alternatively, you can choose to create a directory to store your results. In the command below, we created a directory and downloaded our job output to be stored in that directory.
%%bashrm-rfresults&&mkdir-presults# Temporary directory to store the resultsbacalhauget $JOB_ID --output-dirresults# Download the results
After the download has finished you should see the following contents in results directory.
You can publish your results to Amazon s3 or other S3-compatible destinations like MinIO, Ceph, or SeaweedFS to conveniently store and share your outputs.
Publisher Spec
To facilitate publishing results, define publishers and their configurations using the PublisherSpec structure.
For S3-compatible destinations, the configuration is as follows:
typePublisherSpecstruct { Type Publisher`json:"Type,omitempty"` Params map[string]interface{} `json:"Params,omitempty"`}
For Amazon S3, you can specify the PublisherSpec configuration as shown below:
PublisherSpec:Type:S3Params:Bucket:<bucket># Specify the bucket where results will be storedKey:<object-key># Define the object key (supports dynamic naming using placeholders)Endpoint:<optional># Optionally specify the S3 endpointRegion:<optional># Optionally specify the S3 region
Example Usage
Let's explore some examples to illustrate how you can use this:
Publishing results to S3 using default settings
bacalhau docker run -p s3://<bucket>/<object-key> ubuntu ...
Publishing results to S3 with a custom endpoint and region:
bacalhau docker run -p s3://<bucket>/<object-key>,opt=endpoint=http://s3.example.com,opt=region=us-east-1 ubuntu ...
Publishing results to S3 as a single compressed file
bacalhau docker run -p s3://<bucket>/<object-key> ubuntu ...
Utilizing naming placeholders in the object key
bacalhau docker run -p s3://<bucket>/result-{date}-{jobID} ubuntu ...
Content Identification
Tracking content identification and maintaining lineage across different jobs' inputs and outputs can be challenging. To address this, the publisher encodes the SHA-256 checksum of the published results, specifically when publishing a single compressed file.
To enable support for the S3-compatible storage provider, no additional dependencies are required. However, valid AWS credentials are necessary to sign the requests. The storage provider uses the default credentials chain, which checks the following sources for credentials:
Environment variables, such as AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
Credentials file ~/.aws/credentials
IAM Roles for Amazon EC2 Instances
Need Support?
For questions, feedback, please reach out in our forum