diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e4688f38..e5f5a54d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -20,8 +20,6 @@ }, "runArgs": [ "--name=${localWorkspaceFolderBasename}_devcontainer", - "--cpus=2", - "--memory=8gb", "--privileged", "--cgroupns=host" ], diff --git a/.devcontainer/gpu/Dockerfile b/.devcontainer/gpu/Dockerfile index 1e4092a7..c17ce2ff 100644 --- a/.devcontainer/gpu/Dockerfile +++ b/.devcontainer/gpu/Dockerfile @@ -16,7 +16,7 @@ RUN \ RUN \ # dev setup apt update && \ - apt-get install build-essential sudo jq git bash-completion rsync -y && \ + apt-get install build-essential sudo jq git bash-completion graphviz rsync -y && \ echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \ echo '. /etc/bash_completion' >> /root/.bashrc && \ echo 'export PS1="\[\e[32;1m\]\u\[\e[m\]@\[\e[34;1m\]\H\[\e[m\]:\[\e[33;1m\]\w\[\e[m\]$ "' >> /root/.bashrc && \ @@ -31,6 +31,8 @@ RUN apt-get update && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs # rust code coverage cargo install cargo-llvm-cov && \ rustup component add llvm-tools-preview && \ + # rust crate structure diagram + cargo install cargo-modules && \ apt-get clean ENV PATH=${PATH}:/root/.local/bin diff --git a/.devcontainer/gpu/devcontainer.json b/.devcontainer/gpu/devcontainer.json index 646ee749..137b69dc 100644 --- a/.devcontainer/gpu/devcontainer.json +++ b/.devcontainer/gpu/devcontainer.json @@ -20,8 +20,6 @@ }, "runArgs": [ "--name=${localWorkspaceFolderBasename}_devcontainer", - "--cpus=2", - "--memory=8gb", "--gpus=all", "--privileged", "--cgroupns=host" diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index f7bfc035..126b4469 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -25,7 +25,9 @@ jobs: cargo modules dependencies \ --no-uses --no-fns \ --focus-on "orcapod::model::{Pod}" \ - --layout dot | dot -T svg > docs/crate_diagram.svg + --layout dot | \ + awk '/ERROR/ { print > "/dev/stderr"; next; }; 1' | \ + dot -T svg > docs/crate_diagram.svg - name: Sync GitHub run: | git config user.name github-actions diff --git a/Cargo.toml b/Cargo.toml index c9f02c3b..02b31214 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ categories = [ ] license = "MIT license" -edition = "2021" +edition = "2024" [dependencies] bollard = "0.17.1" # docker API in orchestrator diff --git a/README.md b/README.md index de696191..a96c5c60 100644 --- a/README.md +++ b/README.md @@ -69,4 +69,21 @@ We track only issues in the project so don't add PRs. # based on debian chmod u=rwx,g=rx,o=rx $(find . -not -path "./.git*" -type d | sort) # directories chmod u=rw,g=r,o=r $(find . -not -path "./.git/*" -type f | sort) # files -``` \ No newline at end of file +``` + +## Limit DevContainer Resource Access + +You can easily enforce resource limits by adding the following to `devcontainer.json`. + +```json +{ + // .. + "runArgs": [ + // .. + "--cpus=2",, + "--memory=8gb", + // .. + ], + // .. +} +``` diff --git a/src/error.rs b/src/error.rs index 8e52636c..7d9b54bf 100644 --- a/src/error.rs +++ b/src/error.rs @@ -14,7 +14,9 @@ pub type Result = result::Result; /// Possible errors you may encounter. #[derive(Error, Debug)] pub(crate) enum Kind { - #[error("Received an empty response when attempting to load the alternate container image file: {path}.")] + #[error( + "Received an empty response when attempting to load the alternate container image file: {path}." + )] EmptyResponseWhenLoadingContainerAltImage { path: PathBuf }, #[error("Out of generated random names.")] GeneratedNamesOverflow, diff --git a/src/orchestrator/docker.rs b/src/orchestrator/docker.rs index 565bde64..cfad79ca 100644 --- a/src/orchestrator/docker.rs +++ b/src/orchestrator/docker.rs @@ -5,13 +5,13 @@ use crate::{ util::get, }; use bollard::{ + Docker, container::{ Config, CreateContainerOptions, ListContainersOptions, RemoveContainerOptions, StartContainerOptions, WaitContainerOptions, }, image::{CreateImageOptions, ImportImageOptions}, models::{ContainerStateStatusEnum, HostConfig}, - Docker, }; use chrono::DateTime; use futures_util::{ diff --git a/src/store/filestore.rs b/src/store/filestore.rs index 804df3cc..352065c3 100644 --- a/src/store/filestore.rs +++ b/src/store/filestore.rs @@ -1,6 +1,6 @@ use crate::{ error::{Kind, OrcaError, Result}, - model::{to_yaml, Annotation, Pod, PodJob, PodResult}, + model::{Annotation, Pod, PodJob, PodResult, to_yaml}, store::{ModelID, ModelInfo, Store}, util::get_type_name, }; @@ -8,7 +8,7 @@ use colored::Colorize as _; use glob::glob; use heck::ToSnakeCase as _; use regex::Regex; -use serde::{de::DeserializeOwned, Serialize}; +use serde::{Serialize, de::DeserializeOwned}; use serde_yaml; use std::{ fs, diff --git a/tests/model.rs b/tests/model.rs index e129b738..1a73a452 100644 --- a/tests/model.rs +++ b/tests/model.rs @@ -1,7 +1,7 @@ #![expect(missing_docs, clippy::panic_in_result_fn, reason = "OK in tests.")] pub mod fixture; -use fixture::{pod_job_style, pod_result_style, pod_style, NAMESPACE_LOOKUP_READ_ONLY}; +use fixture::{NAMESPACE_LOOKUP_READ_ONLY, pod_job_style, pod_result_style, pod_style}; use indoc::indoc; use orcapod::{error::Result, model::to_yaml}; diff --git a/tests/orchestrator.rs b/tests/orchestrator.rs index 70c397b6..ffa35226 100644 --- a/tests/orchestrator.rs +++ b/tests/orchestrator.rs @@ -6,11 +6,11 @@ )] pub mod fixture; -use fixture::{container_image_style, pod_job_style, TestContainerImage, TestDirs}; +use fixture::{TestContainerImage, TestDirs, container_image_style, pod_job_style}; use orcapod::{ error::Result, model::OrcaPath, - orchestrator::{docker::LocalDockerOrchestrator, ImageKind, Orchestrator as _, PodRun, Status}, + orchestrator::{ImageKind, Orchestrator as _, PodRun, Status, docker::LocalDockerOrchestrator}, }; use std::{collections::HashMap, path::PathBuf}; diff --git a/tests/store.rs b/tests/store.rs index 9f2b43e1..98265317 100644 --- a/tests/store.rs +++ b/tests/store.rs @@ -8,13 +8,13 @@ pub mod fixture; use fixture::{ - pod_job_style, pod_result_style, pod_style, TestDirs, TestSetup, NAMESPACE_LOOKUP_READ_ONLY, + NAMESPACE_LOOKUP_READ_ONLY, TestDirs, TestSetup, pod_job_style, pod_result_style, pod_style, }; use orcapod::{ crypto::hash_buffer, error::Result, - model::{to_yaml, Annotation, Pod}, - store::{filestore::LocalFileStore, ModelID, ModelInfo, Store as _}, + model::{Annotation, Pod, to_yaml}, + store::{ModelID, ModelInfo, Store as _, filestore::LocalFileStore}, }; use std::{collections::HashMap, fmt::Debug, path::Path};