Skip to content

Commit

Permalink
Prepare the "new-engine" branch to become main
Browse files Browse the repository at this point in the history
This commit contains clippy lints, fixes and general cleanup for making
the contents of the "new-engine" branch become main.

Signed-off-by: Nick Gerace <[email protected]>
Co-authored-by: Zachary Hamm <[email protected]>
Co-authored-by: Paulo Cabral Sanz <[email protected]>
Co-authored-by: Scott Prutton <[email protected]>
Co-authored-by: Paul Stack <[email protected]>
Co-authored-by: Brit Myers <[email protected]>
Co-authored-by: Fletcher Nichol <[email protected]>
Co-authored-by: Adam Jacob <[email protected]>
  • Loading branch information
8 people committed Mar 4, 2024
1 parent db4f957 commit 9a055e6
Show file tree
Hide file tree
Showing 27 changed files with 111 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { DirectedGraph } from "graphology";
import Sigma from "sigma";
import FA2Layout from "graphology-layout-forceatlas2/worker";
import forceAtlas2 from "graphology-layout-forceatlas2";
import noverlap, { NoverlapLayoutParameters } from "graphology-layout-noverlap";
import { useVizStore } from "@/store/viz.store";
const vizStore = useVizStore();
Expand Down
2 changes: 1 addition & 1 deletion bin/sdf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async fn async_main() -> Result<()> {
let symmetric_crypto_service =
Server::create_symmetric_crypto_service(config.symmetric_crypto_service()).await?;

let pkgs_path: PathBuf = config.pkgs_path().try_into()?;
let pkgs_path: PathBuf = config.pkgs_path().into();

let module_index_url = config.module_index_url().to_string();

Expand Down
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@

pinga = binDerivation {pkgName = "pinga";};

rebaser = binDerivation {pkgName = "rebaser";};

sdf = binDerivation {pkgName = "sdf";};

si = binDerivation {pkgName = "si";};
Expand Down
3 changes: 1 addition & 2 deletions lib/cyclone-server/src/tower.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub use limit_requests::{LimitRequest, LimitRequestLayer};
pub use web_socket_trace::{WebSocketTrace, WebSocketTraceLayer};
pub use web_socket_trace::WebSocketTraceLayer;

mod limit_requests {
use std::{
Expand Down
2 changes: 1 addition & 1 deletion lib/dal/src/attribute/prototype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl AttributePrototype {
.into());
}

Ok(match maybe_value_idxs.get(0).copied() {
Ok(match maybe_value_idxs.first().copied() {
Some(value_idx) => {
if let NodeWeight::AttributeValue(av_node_weight) =
workspace_snapshot.get_node_weight(value_idx)?
Expand Down
4 changes: 2 additions & 2 deletions lib/dal/src/attribute/prototype/argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl AttributePrototypeArgument {
return Err(AttributePrototypeArgumentError::InterComponentDestinationPrototypeHasTooManyFuncArgs(destination_attribute_prototype_id));
}

let func_arg_id = func_arg_ids.get(0).ok_or(
let func_arg_id = func_arg_ids.first().ok_or(
AttributePrototypeArgumentError::InterComponentDestinationPrototypeHasNoFuncArgs(
destination_attribute_prototype_id,
),
Expand Down Expand Up @@ -384,7 +384,7 @@ impl AttributePrototypeArgument {
}

let prototype_idx = prototype_idxs
.get(0)
.first()
.copied()
.expect("checked length above");

Expand Down
29 changes: 14 additions & 15 deletions lib/dal/src/attribute/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ impl AttributeValue {
))?;
}

if let Some(prop_target) = prop_targets.get(0).copied() {
if let Some(prop_target) = prop_targets.first().copied() {
let prop_id = workspace_snapshot
.get_node_weight(prop_target)?
.get_prop_node_weight()?
Expand All @@ -465,7 +465,7 @@ impl AttributeValue {
}

let provider_target = provider_targets
.get(0)
.first()
.ok_or(AttributeValueError::OrphanedAttributeValue(value_id))?;

let provider_node_weight = workspace_snapshot.get_node_weight(*provider_target)?;
Expand Down Expand Up @@ -729,7 +729,7 @@ impl AttributeValue {
current_attribute_value_id,
EdgeWeightKindDiscriminants::Contain,
)?
.get(0)
.first()
.copied()
{
current_attribute_value_id = workspace_snapshot
Expand All @@ -745,7 +745,7 @@ impl AttributeValue {
current_attribute_value_id,
EdgeWeightKindDiscriminants::Root,
)?
.get(0)
.first()
.copied()
{
Some(component_target) => component_target,
Expand All @@ -754,7 +754,7 @@ impl AttributeValue {
current_attribute_value_id,
EdgeWeightKindDiscriminants::Socket,
)?
.get(0)
.first()
.copied()
.ok_or(AttributeValueError::OrphanedAttributeValue(
current_attribute_value_id,
Expand Down Expand Up @@ -782,7 +782,7 @@ impl AttributeValue {
parent_attribute_value_id,
EdgeWeightKindDiscriminants::Prop,
)?
.get(0)
.first()
.copied()
.ok_or(AttributeValueError::MissingPropEdge(
parent_attribute_value_id,
Expand Down Expand Up @@ -811,7 +811,7 @@ impl AttributeValue {
return Err(AttributeValueError::PropMoreThanOneChild(prop_id));
}
let element_prop_index = child_prop_indices
.get(0)
.first()
.ok_or(AttributeValueError::PropMissingElementProp(prop_id))?
.to_owned();

Expand Down Expand Up @@ -1312,7 +1312,7 @@ impl AttributeValue {
}

let element_prop_index = child_props
.get(0)
.first()
.ok_or(AttributeValueError::PropMissingElementProp(prop_id))?
.to_owned();

Expand Down Expand Up @@ -1368,7 +1368,7 @@ impl AttributeValue {
attribute_value_id,
EdgeWeightKindDiscriminants::Contain,
)?
.get(0)
.first()
.copied()
{
Some(parent_idx) => {
Expand All @@ -1394,7 +1394,7 @@ impl AttributeValue {
attribute_value_id,
EdgeWeightKindDiscriminants::Prototype,
)?
.get(0)
.first()
.copied();

Ok(match maybe_prototype_idx {
Expand Down Expand Up @@ -1472,11 +1472,10 @@ impl AttributeValue {
Ok(workspace_snapshot
.edges_directed(attribute_value_id, Incoming)?
.find(|edge_ref| matches!(edge_ref.weight().kind(), EdgeWeightKind::Contain(Some(_))))
.map(|edge_ref| match edge_ref.weight().kind() {
.and_then(|edge_ref| match edge_ref.weight().kind() {
EdgeWeightKind::Contain(key) => key.to_owned(),
_ => None,
})
.flatten())
}))
}

/// Returns the most specific prototype id for this attribute value. If a component specific
Expand Down Expand Up @@ -1537,7 +1536,7 @@ impl AttributeValue {
}

let element_prop_index = child_props
.get(0)
.first()
.ok_or(AttributeValueError::PropMissingElementProp(prop_id))?
.to_owned();

Expand Down Expand Up @@ -1651,7 +1650,7 @@ impl AttributeValue {
Some(value) => {
let func_arg_id = *FuncArgument::list_ids_for_func(ctx, func_id)
.await?
.get(0)
.first()
.ok_or(FuncArgumentError::IntrinsicMissingFuncArgumentEdge(
intrinsic_func.name().into(),
func_id,
Expand Down
5 changes: 3 additions & 2 deletions lib/dal/src/attribute/value/dependent_value_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl DependentValueGraph {
pub async fn debug_dot(&self, ctx: &DalContext, suffix: Option<&str>) {
let mut is_for_map = HashMap::new();

for (attribute_value_id, _) in &self.id_to_index_map {
for attribute_value_id in self.id_to_index_map.keys() {
let is_for: String = match AttributeValue::is_for(ctx, *attribute_value_id)
.await
.expect("able to get value is for")
Expand All @@ -153,7 +153,8 @@ impl DependentValueGraph {
let attribute_value_id = *attribute_value_id;
let is_for = is_for_map.clone();

let is_for_string = (&is_for.clone())
let is_for_string = is_for
.clone()
.get(&attribute_value_id)
.map(ToOwned::to_owned)
.expect("is for exists for every value");
Expand Down
3 changes: 1 addition & 2 deletions lib/dal/src/component/qualification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ impl Component {
.as_slice(),
)
.await?
.iter()
.next()
.first()
.copied()
.ok_or(ComponentError::MissingQualificationsValue(component_id))?;

Expand Down
24 changes: 14 additions & 10 deletions lib/dal/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ use crate::workspace_snapshot::WorkspaceSnapshotId;
use crate::{
change_set_pointer::{ChangeSetPointer, ChangeSetPointerId},
job::{
definition::{FixesJob, RefreshJob},
processor::{JobQueueProcessor, JobQueueProcessorError},
producer::{BlockingJobError, BlockingJobResult, JobProducer},
queue::JobQueue,
},
workspace_snapshot::WorkspaceSnapshotError,
HistoryActor, StandardModel, Tenancy, TenancyError, Visibility, WorkspacePk, WorkspaceSnapshot,
AttributeValueId, ComponentId, HistoryActor, StandardModel, Tenancy, TenancyError, Visibility,
WorkspacePk, WorkspaceSnapshot,
};
use crate::{ChangeSetPk, Workspace};

Expand Down Expand Up @@ -674,15 +674,16 @@ impl DalContext {
Ok(())
}

pub async fn enqueue_fix(&self, job: Box<FixesJob>) -> Result<(), TransactionsError> {
self.txns().await?.job_queue.enqueue_job(job).await;
Ok(())
}
// pub async fn enqueue_fix(&self, job: Box<FixesJob>) -> Result<(), TransactionsError> {
// self.txns().await?.job_queue.enqueue_job(job).await;
// Ok(())
// }
//

pub async fn enqueue_refresh(&self, job: Box<RefreshJob>) -> Result<(), TransactionsError> {
self.txns().await?.job_queue.enqueue_job(job).await;
Ok(())
}
// pub async fn enqueue_refresh(&self, job: Box<RefreshJob>) -> Result<(), TransactionsError> {
// self.txns().await?.job_queue.enqueue_job(job).await;
// Ok(())
// }

pub async fn enqueue_dependent_values_update(
&self,
Expand Down Expand Up @@ -1111,6 +1112,9 @@ pub struct Transactions {
rebaser_config: RebaserClientConfig,
job_processor: Box<dyn JobQueueProcessor + Send + Sync>,
job_queue: JobQueue,
#[allow(clippy::type_complexity)]
dependencies_update_component:
Arc<Mutex<HashMap<(Tenancy, ChangeSetPk), HashSet<ComponentId>>>>,
}

#[derive(Clone, Debug)]
Expand Down
6 changes: 3 additions & 3 deletions lib/dal/src/diagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub type DiagramResult<T> = Result<T, DiagramError>;

#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
struct GridPoint {
pub struct GridPoint {
pub x: isize,
pub y: isize,
}
Expand Down Expand Up @@ -176,7 +176,7 @@ pub struct DiagramSocket {
)]
#[serde(rename_all = "camelCase")]
#[strum(serialize_all = "camelCase")]
enum DiagramSocketDirection {
pub enum DiagramSocketDirection {
Bidirectional,
Input,
Output,
Expand All @@ -198,7 +198,7 @@ enum DiagramSocketDirection {
)]
#[serde(rename_all = "camelCase")]
#[strum(serialize_all = "camelCase")]
enum DiagramSocketNodeSide {
pub enum DiagramSocketNodeSide {
Left,
Right,
}
Expand Down
1 change: 1 addition & 0 deletions lib/dal/src/job/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use thiserror::Error;
use tokio::task::JoinError;

use crate::prop::PropError;
use crate::validation::resolver::ValidationResolverError;
use crate::{
attribute::value::AttributeValueError,
job::definition::dependent_values_update::DependentValueUpdateError,
Expand Down
3 changes: 2 additions & 1 deletion lib/dal/src/job/queue.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::producer::JobProducer;
use crate::{AccessBuilder, AttributeValueId, ChangeSetPk, DependentValuesUpdate, Visibility};
use crate::job::definition::DependentValuesUpdate;
use crate::{AccessBuilder, AttributeValueId, ChangeSetPk, Visibility};
use std::{collections::HashMap, collections::HashSet, collections::VecDeque, sync::Arc};
use tokio::sync::Mutex;

Expand Down
2 changes: 1 addition & 1 deletion lib/dal/src/pkg/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::{AttributePrototype, AttributePrototypeId};
use super::{PkgError, PkgResult};

#[derive(Clone, Debug)]
enum Thing {
pub(crate) enum Thing {
ActionPrototype(ActionPrototype),
AuthPrototype(AuthenticationPrototype),
// AttributePrototypeArgument(AttributePrototypeArgument),
Expand Down
9 changes: 4 additions & 5 deletions lib/dal/src/prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl Prop {
let workspace_snapshot = ctx.workspace_snapshot()?.read().await;
match workspace_snapshot
.incoming_sources_for_edge_weight_kind(prop_id, EdgeWeightKindDiscriminants::Use)?
.get(0)
.first()
{
Some(parent_node_idx) => Ok(
match workspace_snapshot.get_node_weight(*parent_node_idx)? {
Expand Down Expand Up @@ -411,8 +411,7 @@ impl Prop {
workspace_snapshot
.get_node_weight(edge_ref.target())
.ok()
.map(|node_weight| node_weight.get_prop_node_weight().ok())
.flatten()
.and_then(|node_weight| node_weight.get_prop_node_weight().ok())
.map(|prop_node| prop_node.id().into())
})
.collect())
Expand Down Expand Up @@ -754,7 +753,7 @@ impl Prop {
let workspace_snapshot = ctx.workspace_snapshot()?.read().await;
let prototype_node_index = *workspace_snapshot
.outgoing_targets_for_edge_weight_kind(prop_id, EdgeWeightKindDiscriminants::Prototype)?
.get(0)
.first()
.ok_or(PropError::MissingPrototypeForProp(prop_id))?;

Ok(workspace_snapshot
Expand Down Expand Up @@ -783,7 +782,7 @@ impl Prop {
let intrinsic_id = Func::find_intrinsic(ctx, intrinsic).await?;
let func_arg_id = *FuncArgument::list_ids_for_func(ctx, intrinsic_id)
.await?
.get(0)
.first()
.ok_or(FuncArgumentError::IntrinsicMissingFuncArgumentEdge(
intrinsic.name().into(),
intrinsic_id,
Expand Down
9 changes: 6 additions & 3 deletions lib/dal/src/provider/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,12 @@ impl ExternalProvider {
let mut result = vec![];
for node_index in node_indices {
let node_weight = workspace_snapshot.get_node_weight(node_index)?;
if let Some(_) = node_weight.get_option_content_node_weight_of_kind(
ContentAddressDiscriminants::ExternalProvider,
) {
if node_weight
.get_option_content_node_weight_of_kind(
ContentAddressDiscriminants::ExternalProvider,
)
.is_some()
{
result.push(node_weight.id().into())
}
}
Expand Down
Loading

0 comments on commit 9a055e6

Please sign in to comment.