if i'm copying a set of files from one sftp folder...
# ask-ai
m
if i'm copying a set of files from one sftp folder to another, am i better to use ops or assets?
s
For copying a set of files from one SFTP folder to another within Dagster, we recommend using assets. Assets in Dagster are a way to define and manage your data as it flows through your pipelines. They allow you to track the lineage of your data and understand how it's produced and consumed by different parts of your system. Here's an example from the documentation on how you might define an asset that performs an SFTP operation using the
dagster_ssh
library:
Copy code
python from dagster import asset, with_resources from dagster_ssh import ssh_resource  @asset(required_resource_keys={'ssh'}) def my_asset(context):     context.resources.ssh.sftp_get("/path/to/remote.csv", "path/to/local.csv")  assets = with_resources([my_asset], resource_defs={     'ssh': ssh_resource.configured({         'remote_host': '<http://foo.com|foo.com>',         'key_file': 'path/to/id_rsa',     }) })
In this example,
my_asset
is an asset that uses an SSH resource to perform an SFTP operation. You can adapt this example to perform the file copying operation you need. By using assets, you can take advantage of Dagster's asset catalog, which provides observability into the production and consumption of your data assets. Remember that assets are the preferred abstraction in Dagster for defining data computations and dependencies, especially in the context of data pipelines where tracking and managing data is a primary concern.