diff --git a/crates/maelstrom-client-base/src/items.proto b/crates/maelstrom-client-base/src/items.proto index a7d10b4e..ed892391 100644 --- a/crates/maelstrom-client-base/src/items.proto +++ b/crates/maelstrom-client-base/src/items.proto @@ -153,7 +153,7 @@ enum ImageUse { IMAGE_USE_WORKING_DIRECTORY = 2; } -message ImageSpec { +message ImageRef { string name = 1; repeated ImageUse use = 2; } @@ -186,7 +186,7 @@ message JobTty { message ContainerParent { oneof parent { - ImageSpec image = 1; + ImageRef image = 1; ContainerRef container = 2; } } diff --git a/crates/maelstrom-client-base/src/spec.rs b/crates/maelstrom-client-base/src/spec.rs index 43ad535a..fb855408 100644 --- a/crates/maelstrom-client-base/src/spec.rs +++ b/crates/maelstrom-client-base/src/spec.rs @@ -48,8 +48,8 @@ where } #[derive(Clone, Debug, Eq, Hash, IntoProtoBuf, Ord, PartialEq, PartialOrd, TryFromProtoBuf)] -#[proto(proto_buf_type = "proto::ImageSpec")] -pub struct ImageSpec { +#[proto(proto_buf_type = "proto::ImageRef")] +pub struct ImageRef { pub name: String, pub r#use: EnumSet, } @@ -67,7 +67,7 @@ pub struct ContainerRef { enum_type = "proto::container_parent::Parent" )] pub enum ContainerParent { - Image(ImageSpec), + Image(ImageRef), Container(ContainerRef), } @@ -75,7 +75,7 @@ pub enum ContainerParent { macro_rules! image_container_parent { (@expand [] -> [$name:expr, $layers:literal, $environment:literal, $working_directory:literal]) => { $crate::spec::ContainerParent::Image( - $crate::spec::ImageSpec { + $crate::spec::ImageRef { name: $name.into(), r#use: { let mut r#use = EnumSet::new(); diff --git a/crates/maelstrom-client-process/src/preparer.rs b/crates/maelstrom-client-process/src/preparer.rs index 5b9640e1..84de1088 100644 --- a/crates/maelstrom-client-process/src/preparer.rs +++ b/crates/maelstrom-client-process/src/preparer.rs @@ -5,7 +5,7 @@ use maelstrom_base::{ NonEmpty, Sha256Digest, Timeout, UserId, Utf8PathBuf, }; use maelstrom_client_base::spec::{ - ContainerParent, ContainerSpec, ConvertedImage, EnvironmentSpec, ImageSpec, ImageUse, + ContainerParent, ContainerSpec, ConvertedImage, EnvironmentSpec, ImageRef, ImageUse, JobSpec as ClientJobSpec, LayerSpec, }; use maelstrom_util::ext::OptionExt as _; @@ -162,7 +162,7 @@ impl Preparer { let (pending_image, get_image) = { match container.parent { None | Some(ContainerParent::Container(_)) => (None, None), - Some(ContainerParent::Image(ImageSpec { name, r#use })) => { + Some(ContainerParent::Image(ImageRef { name, r#use })) => { if r#use.is_empty() { (None, None) } else { diff --git a/crates/maelstrom-pytest/src/lib.rs b/crates/maelstrom-pytest/src/lib.rs index 4646c54f..8d8b6e52 100644 --- a/crates/maelstrom-pytest/src/lib.rs +++ b/crates/maelstrom-pytest/src/lib.rs @@ -10,7 +10,7 @@ use maelstrom_base::{ }; use maelstrom_client::{ job_spec, - spec::{ImageSpec, LayerSpec, PrefixOptions}, + spec::{ImageRef, LayerSpec, PrefixOptions}, AcceptInvalidRemoteContainerTlsCerts, CacheDir, Client, ClientBgProcess, ContainerImageDepotDir, ContainerParent, ProjectDir, StateDir, }; @@ -169,13 +169,13 @@ struct PytestTestCollector<'client> { build_dir: RootBuf, cache_dir: RootBuf, client: &'client Client, - test_layers: Mutex>, + test_layers: Mutex>, } impl PytestTestCollector<'_> { fn get_pip_packages( &self, - image_spec: ImageSpec, + image_spec: ImageRef, ref_: &DockerReference, ui: &UiSender, ) -> Result { @@ -308,7 +308,7 @@ impl PytestTestCollector<'_> { Ok(upper.try_into()?) } - fn build_test_layer(&self, image: ImageSpec, ui: &UiSender) -> Result> { + fn build_test_layer(&self, image: ImageRef, ui: &UiSender) -> Result> { let image_name: ImageName = image.name.parse()?; let ImageName::Docker(ref_) = image_name else { return Ok(None); @@ -336,7 +336,7 @@ pub(crate) struct PytestTestArtifact { ignored_tests: Vec, package: PytestPackageId, pytest_options: PytestConfigValues, - test_layers: HashMap, + test_layers: HashMap, } #[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq)] @@ -468,7 +468,7 @@ impl CollectTests for PytestTestCollector<'_> { Ok((handle, stream)) } - fn build_test_layers(&self, images: Vec, ui: &UiSender) -> Result<()> { + fn build_test_layers(&self, images: Vec, ui: &UiSender) -> Result<()> { let mut test_layers = self.test_layers.lock().unwrap(); for image in images { if let Entry::Vacant(e) = test_layers.entry(image.clone()) { diff --git a/crates/maelstrom-pytest/src/pytest.rs b/crates/maelstrom-pytest/src/pytest.rs index e9b0cf0a..aeff3260 100644 --- a/crates/maelstrom-pytest/src/pytest.rs +++ b/crates/maelstrom-pytest/src/pytest.rs @@ -3,7 +3,7 @@ use crate::{ }; use anyhow::{anyhow, bail, Result}; use maelstrom_client::{ - spec::{ImageSpec, LayerSpec}, + spec::{ImageRef, LayerSpec}, ProjectDir, }; use maelstrom_test_runner::WaitStatus; @@ -123,7 +123,7 @@ pub fn pytest_collect_tests( pytest_options: &PytestConfigValues, project_dir: &Root, build_dir: &Root, - test_layers: HashMap, + test_layers: HashMap, ) -> Result<(WaitHandle, TestArtifactStream)> { compile_python(project_dir.as_ref())?; diff --git a/crates/maelstrom-run/src/spec.rs b/crates/maelstrom-run/src/spec.rs index 6ed9c5b0..5431ef69 100644 --- a/crates/maelstrom-run/src/spec.rs +++ b/crates/maelstrom-run/src/spec.rs @@ -4,7 +4,7 @@ use maelstrom_base::{ UserId, Utf8PathBuf, }; use maelstrom_client::spec::{ - incompatible, ContainerParent, ContainerSpec, EnvironmentSpec, Image, ImageSpec, ImageUse, + incompatible, ContainerParent, ContainerSpec, EnvironmentSpec, Image, ImageRef, ImageUse, IntoEnvironment, JobSpec, LayerSpec, PossiblyImage, }; use serde::de::Error as _; @@ -108,7 +108,7 @@ impl Job { } }; let parent = self.image.map(|image| { - ContainerParent::Image(ImageSpec { + ContainerParent::Image(ImageRef { name: image, r#use: image_use, }) diff --git a/crates/maelstrom-test-runner/src/deps.rs b/crates/maelstrom-test-runner/src/deps.rs index debf3d22..2cc6982a 100644 --- a/crates/maelstrom-test-runner/src/deps.rs +++ b/crates/maelstrom-test-runner/src/deps.rs @@ -1,7 +1,7 @@ use crate::{metadata::TestMetadata, ui}; use anyhow::Result; use maelstrom_base::Utf8PathBuf; -use maelstrom_client::spec::{ImageSpec, LayerSpec}; +use maelstrom_client::spec::{ImageRef, LayerSpec}; use maelstrom_util::{process::ExitCode, template::TemplateVars}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::{ @@ -246,7 +246,7 @@ pub trait CollectTests { fn get_packages(&self, ui: &ui::UiSender) -> Result>; /// Build any test layers that might want to be used later. This function is allowed to block. - fn build_test_layers(&self, _images: Vec, _ui: &ui::UiSender) -> Result<()> { + fn build_test_layers(&self, _images: Vec, _ui: &ui::UiSender) -> Result<()> { Ok(()) } } diff --git a/crates/maelstrom-test-runner/src/metadata.rs b/crates/maelstrom-test-runner/src/metadata.rs index a65bcfce..af1cf3e9 100644 --- a/crates/maelstrom-test-runner/src/metadata.rs +++ b/crates/maelstrom-test-runner/src/metadata.rs @@ -7,7 +7,7 @@ use container::TestContainer; use directive::TestDirective; use maelstrom_base::{EnumSet, GroupId, JobMount, JobNetwork, Timeout, UserId, Utf8PathBuf}; use maelstrom_client::{ - spec::{ContainerParent, EnvironmentSpec, ImageSpec, ImageUse, LayerSpec, PossiblyImage}, + spec::{ContainerParent, EnvironmentSpec, ImageRef, ImageUse, LayerSpec, PossiblyImage}, ProjectDir, }; use maelstrom_util::{fs::Fs, root::Root, template::TemplateVars}; @@ -110,7 +110,7 @@ impl TestMetadataContainer { if container.image.is_some() { self.parent = container.image.as_ref().map(|image| { - ContainerParent::Image(ImageSpec { + ContainerParent::Image(ImageRef { name: image.into(), r#use: image_use, }) @@ -206,11 +206,11 @@ where .try_fold(TestMetadata::default(), |m, d| m.try_fold(d)) } - pub fn get_all_images(&self) -> Vec { + pub fn get_all_images(&self) -> Vec { self.directives .iter() .filter_map(|directive| { - directive.container.image.as_ref().map(|name| ImageSpec { + directive.container.image.as_ref().map(|name| ImageRef { name: name.into(), r#use: { let mut image_use = EnumSet::new(); diff --git a/py/maelstrom_client/__init__.py b/py/maelstrom_client/__init__.py index 7096341a..4d199037 100644 --- a/py/maelstrom_client/__init__.py +++ b/py/maelstrom_client/__init__.py @@ -8,7 +8,7 @@ Duration, EnvironmentSpec, GlobLayer, - ImageSpec, + ImageRef, ImageUse, JobDevice, JobMount, diff --git a/py/maelstrom_client/client.py b/py/maelstrom_client/client.py index 04c32809..3f7d894b 100644 --- a/py/maelstrom_client/client.py +++ b/py/maelstrom_client/client.py @@ -6,7 +6,7 @@ from typing import Optional, Union, Protocol, Sequence from .items_pb2 import ( GlobLayer, - ImageSpec, + ImageRef, JobMount, JobSpec, PathsLayer, diff --git a/py/run_job.py b/py/run_job.py index 80b4f5f5..8ee184c4 100755 --- a/py/run_job.py +++ b/py/run_job.py @@ -3,7 +3,7 @@ import os import sys -from maelstrom_client import Client, ImageSpec, ContainerSpec, ContainerRef, JobSpec, ImageUse, ContainerParent +from maelstrom_client import Client, ImageRef, ContainerSpec, ContainerRef, JobSpec, ImageUse, ContainerParent def main(): prog=sys.argv[1] @@ -11,7 +11,7 @@ def main(): client = Client(slots=4) - image = ImageSpec(name="docker://alpine", use=[ImageUse.IMAGE_USE_LAYERS]) + image = ImageRef(name="docker://alpine", use=[ImageUse.IMAGE_USE_LAYERS]) container = ContainerSpec(working_directory="/", parent=ContainerParent(image=image)) spec = JobSpec( container=container,