Skip to content

Commit

Permalink
Revert "Make de/serialized structs compliant with Rust naming practic…
Browse files Browse the repository at this point in the history
…es (#1271)" (#1282)

This reverts commit a174fbf.
  • Loading branch information
allada authored Aug 23, 2024
1 parent a174fbf commit 0933c1a
Show file tree
Hide file tree
Showing 31 changed files with 232 additions and 234 deletions.
2 changes: 1 addition & 1 deletion deployment-examples/docker-compose/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN apt-get update \
git=1:2.34.1-1ubuntu1.11 \
gcc=4:11.2.0-1ubuntu1 \
g++=4:11.2.0-1ubuntu1 \
python3=3.10.6-1~22.04 \
python3=3.10.6-1~22.04.1 \
ca-certificates=20230311ubuntu0.22.04.1; \
elif [ "${OS_VERSION}" = "20.04" ]; then \
DEBIAN_FRONTEND=noninteractive \
Expand Down
42 changes: 21 additions & 21 deletions nativelink-config/src/cas_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ pub type SchedulerRefName = String;
/// Used when the config references `instance_name` in the protocol.
pub type InstanceName = String;

#[allow(non_camel_case_types)]
#[derive(Deserialize, Debug, Default, Clone, Copy)]
#[serde(rename_all = "snake_case")]
pub enum HttpCompressionAlgorithm {
/// No compression.
#[default]
None,
none,

/// Zlib compression.
Gzip,
gzip,
}

/// Note: Compressing data in the cloud rarely has a benefit, since most
Expand Down Expand Up @@ -360,11 +360,11 @@ pub struct HttpServerConfig {
pub experimental_http2_max_header_list_size: Option<u32>,
}

#[allow(non_camel_case_types)]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "snake_case")]
pub enum ListenerConfig {
/// Listener for HTTP/HTTPS/HTTP2 sockets.
Http(HttpListener),
http(HttpListener),
}

#[derive(Deserialize, Debug)]
Expand Down Expand Up @@ -408,18 +408,18 @@ pub struct ServerConfig {
pub services: Option<ServicesConfig>,
}

#[allow(non_camel_case_types)]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "snake_case")]
pub enum WorkerProperty {
/// List of static values.
/// Note: Generally there should only ever be 1 value, but if the platform
/// property key is PropertyType::Priority it may have more than one value.
#[serde(deserialize_with = "convert_vec_string_with_shellexpand")]
Values(Vec<String>),
values(Vec<String>),

/// A dynamic configuration. The string will be executed as a command
/// (not sell) and will be split by "\n" (new line character).
QueryCmd(String),
query_cmd(String),
}

/// Generic config for an endpoint and associated configs.
Expand All @@ -438,35 +438,35 @@ pub struct EndpointConfig {
pub tls_config: Option<ClientTlsConfig>,
}

#[allow(non_camel_case_types)]
#[derive(Copy, Clone, Deserialize, Debug, Default)]
#[serde(rename_all = "snake_case")]
pub enum UploadCacheResultsStrategy {
/// Only upload action results with an exit code of 0.
#[default]
SuccessOnly,
success_only,

/// Don't upload any action results.
Never,
never,

/// Upload all action results that complete.
Everything,
everything,

/// Only upload action results that fail.
FailuresOnly,
failures_only,
}

#[allow(non_camel_case_types)]
#[derive(Clone, Deserialize, Debug)]
#[serde(rename_all = "snake_case")]
pub enum EnvironmentSource {
/// The name of the platform property in the action to get the value from.
Property(String),
property(String),

/// The raw value to set.
Value(#[serde(deserialize_with = "convert_string_with_shellexpand")] String),
value(#[serde(deserialize_with = "convert_string_with_shellexpand")] String),

/// The max amount of time in milliseconds the command is allowed to run
/// (requested by the client).
TimeoutMillis,
timeout_millis,

/// A special file path will be provided that can be used to comminicate
/// with the parent process about out-of-band information. This file
Expand All @@ -484,7 +484,7 @@ pub enum EnvironmentSource {
///
/// All fields are optional, file does not need to be created and may be
/// empty.
SideChannelFile,
side_channel_file,

/// A "root" directory for the action. This directory can be used to
/// store temporary files that are not needed after the action has
Expand All @@ -499,7 +499,7 @@ pub enum EnvironmentSource {
/// variable, `mkdir $ENV_VAR_NAME/tmp` and `export TMPDIR=$ENV_VAR_NAME/tmp`.
/// Another example might be to bind-mount the `/tmp` path in a container to
/// this path in `entrypoint`.
ActionDirectory,
action_directory,
}

#[derive(Deserialize, Debug, Default)]
Expand Down Expand Up @@ -653,11 +653,11 @@ pub struct LocalWorkerConfig {
pub additional_environment: Option<HashMap<String, EnvironmentSource>>,
}

#[allow(non_camel_case_types)]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "snake_case")]
pub enum WorkerConfig {
/// A worker type that executes jobs locally on this machine.
Local(LocalWorkerConfig),
local(LocalWorkerConfig),
}

#[derive(Deserialize, Debug, Clone, Copy)]
Expand Down
30 changes: 15 additions & 15 deletions nativelink-config/src/schedulers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,50 +19,50 @@ use serde::Deserialize;
use crate::serde_utils::{convert_duration_with_shellexpand, convert_numeric_with_shellexpand};
use crate::stores::{GrpcEndpoint, Retry, StoreRefName};

#[allow(non_camel_case_types)]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "snake_case")]
pub enum SchedulerConfig {
Simple(SimpleScheduler),
Grpc(GrpcScheduler),
CacheLookup(CacheLookupScheduler),
PropertyModifier(PropertyModifierScheduler),
simple(SimpleScheduler),
grpc(GrpcScheduler),
cache_lookup(CacheLookupScheduler),
property_modifier(PropertyModifierScheduler),
}

/// When the scheduler matches tasks to workers that are capable of running
/// the task, this value will be used to determine how the property is treated.
#[allow(non_camel_case_types)]
#[derive(Deserialize, Debug, Clone, Copy, Hash, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum PropertyType {
/// Requires the platform property to be a u64 and when the scheduler looks
/// for appropriate worker nodes that are capable of executing the task,
/// the task will not run on a node that has less than this value.
Minimum,
minimum,

/// Requires the platform property to be a string and when the scheduler
/// looks for appropriate worker nodes that are capable of executing the
/// task, the task will not run on a node that does not have this property
/// set to the value with exact string match.
Exact,
exact,

/// Does not restrict on this value and instead will be passed to the worker
/// as an informational piece.
/// TODO(allada) In the future this will be used by the scheduler and worker
/// to cause the scheduler to prefer certain workers over others, but not
/// restrict them based on these values.
Priority,
priority,
}

/// When a worker is being searched for to run a job, this will be used
/// on how to choose which worker should run the job when multiple
/// workers are able to run the task.
#[allow(non_camel_case_types)]
#[derive(Copy, Clone, Deserialize, Debug, Default)]
#[serde(rename_all = "snake_case")]
pub enum WorkerAllocationStrategy {
/// Prefer workers that have been least recently used to run a job.
#[default]
LeastRecentlyUsed,
least_recently_used,
/// Prefer workers that have been most recently used to run a job.
MostRecentlyUsed,
most_recently_used,
}

#[derive(Deserialize, Debug, Default)]
Expand Down Expand Up @@ -168,13 +168,13 @@ pub struct PlatformPropertyAddition {
pub value: String,
}

#[allow(non_camel_case_types)]
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "snake_case")]
pub enum PropertyModification {
/// Add a property to the action properties.
Add(PlatformPropertyAddition),
add(PlatformPropertyAddition),
/// Remove a named property from the action.
Remove(String),
remove(String),
}

#[derive(Deserialize, Debug)]
Expand Down
Loading

0 comments on commit 0933c1a

Please sign in to comment.