7 个不稳定版本 (3 个重大更改)
0.4.3 | 2021年11月21日 |
---|---|
0.4.2 | 2021年11月19日 |
0.4.1 | 2021年8月11日 |
0.3.0 | 2021年3月3日 |
0.1.0 | 2020年3月2日 |
在 认证 中排名 #361
每月下载量 26 次
60KB
1.5K SLoC
Xenon for Rust
此 crate 包含 Rust 对 Xenon 的绑定。Xenon 是一个中间件,为科学和高效能计算领域使用的各种软件系统提供统一的接口。这些绑定基于 gRPC,并需要连接到 Xenon gRPC 服务器。与 Xenon 的 Java API 保持一致性。
使用方法
可以使用 Scheduler
和 FileSystem
结构体的实例执行计算和存储操作。可以将特定于所使用适配器的 Xenon 属性传递给实例进行配置(见此处)。
支持两种类型的凭证:常规的用户名/密码组合和(SSH)证书。
use xenon::credentials:Credential;
use xenon::compute::Scheduler;
use xenon::storage::FileSystem;
let xenon_endpoint = "https://127.0.0.1:50051";
let xenon_properties = None;
let slurm_ssh_host = "remote-server:22";
let slurm_ssh_host_cred = Credential::new_password(
"username",
"password",
)
let mut scheduler = Scheduler::create(
"slurm",
slurm_ssh_host,
slurm_ssh_host_cred,
xenon_endpoint,
xenon_properties,
);
let mut filesystem = FileSystem::create(
"sftp",
slurm_ssh_host,
slurm_ssh_host_red,
xenon_endpoint,
xenon_properties,
);
计算
计算操作的选择
方法 | 描述 |
---|---|
cancel_job |
取消一个作业。 |
get_job_status |
获取作业的状态。 |
get_job_statuses |
获取多个作业的状态。 |
get_jobs |
获取所有活动作业的 ID。 |
get_queue_names |
获取可用队列的名称。 |
get_queue_status |
获取队列的状态。 |
get_queue_statuses |
获取所有队列的状态。 |
submit_batch_job |
提交一个批量作业。 |
wait_until_done |
等待作业完成或超时。 |
wait_until_running |
等待作业运行或超时。 |
存储
存储操作的选择
方法 | 描述 |
---|---|
append_to_file |
向文件追加字节。 |
copy |
复制文件。 |
create_directories |
创建一个或多个新目录。 |
create_directory |
创建一个新目录。 |
create_file |
创建一个新文件。 |
create_symbolic_link |
创建符号链接。 |
delete |
删除文件。 |
exists |
检查文件是否存在。 |
read_from_file |
从文件中读取字节。 |
read_symbolic_link |
读取符号链接的目标。 |
rename |
重命名文件。 |
set_permissions |
设置文件或目录的权限。 |
write_to_file |
将字节写入文件。 |
示例
常见计算操作的示例
use xenon::compute::JobDescription;
// Create a job description.
let job_description = JobDescription {
executable: Some(String::from("echo")),
arguments: Some(vec![String::from("Hello, world!")]),
..Default::default()
};
// Submit a batch job.
let job = scheduler.submit_batch_job(job_description).await?;
// Retreive the status of the job.
let job_status = scheduler.get_job_status(job).await?;
println!("Job name: {}", job_status.name);
// Cancel the job, if it not already finished.
let job_status = scheduler.cancel_job(job).await?;
常见存储操作的示例
// Create a new file, if it not already exists.
let example_file = "./example.txt";
if !filesystem.exists(example_file).await? {
filesystem.create_file(example_file).await?;
}
// Append some text to the file.
let text = String::from("Hello, world!\n");
filesystem.append_to_file(text, example_file).await?;
// Read the contents of the file as text.
let bytes = filesystem.read_from_file(example_file).await?;
let text = String::from_utf8(bytes)?;
// Delete the file.
filesystem.delete(example_file, false).await?;
查看示例目录获取更多示例。
依赖项
~8.5MB
~152K SLoC