Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 15 additions & 14 deletions Dockerfile.rls
Comment thread
DanielVoogsgerd marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ RUN adduser --uid $USERID --gid $GROUPID --gecos "Brane" --disabled-password bra
# Copy over relevant crates & other files
RUN mkdir /build && chown -R brane:brane /build
COPY --chown=brane:brane . /build
RUN mkdir /build/build && chown brane:brane /build/build

# Build optimized binaries
USER brane
Expand All @@ -48,13 +49,13 @@ RUN --mount=type=cache,id=cargoidx,uid=$USERID,target=/usr/local/cargo/registry
--package brane-prx \
--package brane-plr \
--package brane-reg \
&& cp ./target/release/brane-api /home/brane/brane-api \
&& cp ./target/release/brane-chk /home/brane/brane-chk \
&& cp ./target/release/brane-drv /home/brane/brane-drv \
&& cp ./target/release/brane-job /home/brane/brane-job \
&& cp ./target/release/brane-prx /home/brane/brane-prx \
&& cp ./target/release/brane-plr /home/brane/brane-plr \
&& cp ./target/release/brane-reg /home/brane/brane-reg
&& cp ./target/release/brane-api /build/build/brane-api \
&& cp ./target/release/brane-chk /build/build/brane-chk \
&& cp ./target/release/brane-drv /build/build/brane-drv \
&& cp ./target/release/brane-job /build/build/brane-job \
&& cp ./target/release/brane-prx /build/build/brane-prx \
&& cp ./target/release/brane-plr /build/build/brane-plr \
&& cp ./target/release/brane-reg /build/build/brane-reg

# If ever run, run a shell
WORKDIR /
Expand Down Expand Up @@ -148,7 +149,7 @@ ENTRYPOINT [ "/bin/bash" ]
FROM brane-base AS brane-prx

# Copy `brane-prx` from build stage
COPY --from=build-brane --chown=brane:brane /home/brane//brane-prx /brane-prx
COPY --from=build-brane --chown=brane:brane /build/build/brane-prx /brane-prx

# Run the compiled executable as base
ENTRYPOINT [ "/brane-prx" ]
Expand All @@ -169,7 +170,7 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*

# Copy `brane-api` from build stage
COPY --from=build-brane --chown=brane:brane /home/brane/brane-api /brane-api
COPY --from=build-brane --chown=brane:brane /build/build/brane-api /brane-api

# Run the compiled executable as base
USER brane
Expand All @@ -184,7 +185,7 @@ ENTRYPOINT [ "/brane-api" ]
FROM brane-base AS brane-drv

# Copy `brane-drv` from build stage
COPY --from=build-brane --chown=brane:brane /home/brane/brane-drv /brane-drv
COPY --from=build-brane --chown=brane:brane /build/build/brane-drv /brane-drv

# Run the compiled executable as base
ENTRYPOINT [ "/brane-drv" ]
Expand All @@ -198,7 +199,7 @@ ENTRYPOINT [ "/brane-drv" ]
FROM brane-base AS brane-plr

# Copy `brane-plr` from build stage
COPY --from=build-brane --chown=brane:brane /home/brane/brane-plr /brane-plr
COPY --from=build-brane --chown=brane:brane /build/build/brane-plr /brane-plr

# Run the compiled executable as base
ENTRYPOINT [ "/brane-plr" ]
Expand All @@ -219,7 +220,7 @@ USER root
RUN adduser brane root

# Copy `brane-job` from build stage
COPY --from=build-brane --chown=brane:brane /home/brane/brane-job /brane-job
COPY --from=build-brane --chown=brane:brane /build/build/brane-job /brane-job

# Run the compiled executable as base
# USER brane
Expand All @@ -234,7 +235,7 @@ ENTRYPOINT [ "/brane-job" ]
FROM brane-base AS brane-reg

# Copy `brane-reg` from build stage
COPY --from=build-brane --chown=brane:brane /home/brane/brane-reg /brane-reg
COPY --from=build-brane --chown=brane:brane /build/build/brane-reg /brane-reg

# Run the compiled executable as base
ENTRYPOINT [ "/brane-reg" ]
Expand All @@ -257,7 +258,7 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*

# Copy `policy-reasoner` from build stage
COPY --from=build-brane --chown=brane:brane /home/brane/brane-chk /brane-chk
COPY --from=build-brane --chown=brane:brane /build/build/brane-chk /brane-chk
RUN chmod +x /brane-chk

# Copy `eflint-repl` from build stage
Expand Down
8 changes: 4 additions & 4 deletions brane-api/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use enum_debug::EnumDebug as _;
use reqwest::StatusCode;
use scylla::transport::errors::NewSessionError;
use specifications::address::Address;
use specifications::version::Version;
use specifications::version::AliasedFunctionVersion;


/***** ERRORS *****/
Expand Down Expand Up @@ -142,16 +142,16 @@ pub enum PackageError {
VersionsQueryError { name: String, source: scylla::transport::errors::QueryError },
/// Failed to parse a Version string
#[error("Failed to parse '{raw}' as a valid version string")]
VersionParseError { raw: String, source: specifications::version::ParseError },
VersionParseError { raw: String, source: specifications::version::SemverError },
/// No versions found for the given package
#[error("No versions found for package '{name}'")]
NoVersionsFound { name: String },
/// Failed to query the database for the file of the given package.
#[error("Failed to get path of package '{name}', version {version}")]
PathQueryError { name: String, version: Version, source: scylla::transport::errors::QueryError },
PathQueryError { name: String, version: AliasedFunctionVersion, source: scylla::transport::errors::QueryError },
/// The given package was unknown.
#[error("No package '{name}' exists (or has version {version})")]
UnknownPackage { name: String, version: Version },
UnknownPackage { name: String, version: AliasedFunctionVersion },
/// Failed to get the metadata of a file.
#[error("Failed to get metadata of file '{}'", path.display())]
FileMetadataError { path: PathBuf, source: std::io::Error },
Expand Down
10 changes: 5 additions & 5 deletions brane-api/src/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use rand::distr::Alphanumeric;
use scylla::macros::{FromUserType, IntoUserType};
use scylla::{SerializeCql, Session};
use specifications::package::PackageInfo;
use specifications::version::Version;
use specifications::version::AliasedFunctionVersion;
// use tar::Archive;
use tempfile::TempDir;
use tokio::fs as tfs;
Expand Down Expand Up @@ -249,21 +249,21 @@ pub async fn download(name: String, version: String, context: Context) -> Result

// Attempt to resolve the version from the Scylla database in the context
debug!("Resolving version '{}'...", version);
let version: Version = if version.to_lowercase() == "latest" {
let version: AliasedFunctionVersion = if version.to_lowercase() == "latest" {
let versions = match context.scylla.query("SELECT version FROM brane.packages WHERE name=?", vec![&name]).await {
Ok(versions) => versions,
Err(source) => {
fail!(Error::VersionsQueryError { name, source });
},
};
let mut latest: Option<Version> = None;
let mut latest: Option<AliasedFunctionVersion> = None;
if let Some(rows) = versions.rows {
for row in rows {
// Get the string value
let version: &str = row.columns[0].as_ref().unwrap().as_text().unwrap();

// Attempt to parse
let version: Version = match Version::from_str(version) {
let version: AliasedFunctionVersion = match AliasedFunctionVersion::from_str(version) {
Ok(version) => version,
Err(source) => {
fail!(Error::VersionParseError { raw: version.into(), source });
Expand All @@ -286,7 +286,7 @@ pub async fn download(name: String, version: String, context: Context) -> Result
},
}
} else {
match Version::from_str(&version) {
match AliasedFunctionVersion::from_str(&version) {
Ok(version) => version,
Err(source) => {
fail!(Error::VersionParseError { raw: version, source });
Expand Down
22 changes: 11 additions & 11 deletions brane-api/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use chrono::{DateTime, TimeZone, Utc};
use juniper::{EmptySubscription, FieldResult, GraphQLObject, RootNode, graphql_object};
use log::{debug, info};
use scylla::IntoTypedRows;
use specifications::version::Version;
use specifications::version::{AliasedFunctionVersion, ConcreteFunctionVersion};

use crate::packages::PackageUdt;
use crate::spec::Context;
Expand Down Expand Up @@ -97,42 +97,42 @@ impl Query {

// Now find the target version if relevant
if let Some(version) = version {
let target_version: Version = Version::from_str(&version)?;
let target_version = AliasedFunctionVersion::from_str(&version)?;
let mut package: Option<Package> = None;
let mut version: Option<Version> = None;
if target_version.is_latest() {
let mut version: Option<ConcreteFunctionVersion> = None;
if let AliasedFunctionVersion::Version(semver) = target_version {
for p in packages {
// Find the one with the highest version
// Find the first matching one

// Parse it as a version
let pversion: Version = match Version::from_str(&p.version) {
let pversion = match ConcreteFunctionVersion::from_str(&p.version) {
Ok(version) => version,
Err(_) => {
continue;
},
};

// Compare
if package.is_none() || &pversion > version.as_ref().unwrap() {
if semver == pversion {
package = Some(p);
version = Some(pversion);
}
}
} else {
for p in packages {
// Find the first matching one
// Find the one with the highest version

// Parse it as a version
let pversion: Version = match Version::from_str(&p.version) {
let pversion = match ConcreteFunctionVersion::from_str(&p.version) {
Ok(version) => version,
Err(_) => {
continue;
},
};

// Compare
if target_version == pversion {
if package.is_none() || &pversion > version.as_ref().unwrap() {
package = Some(p);
version = Some(pversion);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions brane-ast/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::io::Write;
use brane_dsl::ast::Expr;
use brane_dsl::{DataType, TextRange};
use console::{Style, style};
use specifications::version::Version;
use specifications::version::AliasedFunctionVersion;
use specifications::wir::builtins::BuiltinClasses;
use specifications::wir::merge_strategy::MergeStrategy;

Expand Down Expand Up @@ -508,10 +508,10 @@ impl SanityError {
pub enum ResolveError {
/// Failed to parse a package version number.
#[error("Failed to parse package version")]
VersionParseError { source: specifications::version::ParseError, range: TextRange },
VersionParseError { source: specifications::version::SemverError, range: TextRange },
/// The given package/version pair was not found.
#[error("Package '{}' does not exist{}", name, if !version.is_latest() { format!(" or has no version '{version}'") } else { String::new() })]
UnknownPackageError { name: String, version: Version, range: TextRange },
UnknownPackageError { name: String, version: AliasedFunctionVersion, range: TextRange },
/// Failed to declare an imported package function
#[error("Could not import function '{name}' from package '{package_name}'")]
FunctionImportError { package_name: String, name: String, source: brane_dsl::errors::SymbolTableError, range: TextRange },
Expand Down
10 changes: 5 additions & 5 deletions brane-ast/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use brane_dsl::data_type::{ClassSignature, FunctionSignature};
use brane_dsl::symbol_table::{ClassEntry, FunctionEntry, SymbolTable, VarEntry};
use brane_dsl::{DataType, TextRange};
use specifications::package::Capability;
use specifications::version::Version;
use specifications::version::ConcreteFunctionVersion;
use specifications::wir::builtins::{BuiltinClasses, BuiltinFunctions};
use specifications::wir::{ClassDef, ComputeTaskDef, Edge, FunctionDef, SymTable, TaskDef, VarDef};
use strum::IntoEnumIterator;
Expand Down Expand Up @@ -380,7 +380,7 @@ pub struct TaskState {
/// The name of the package where this Task is stored.
pub package_name: String,
/// The version of the package where this Task is stored.
pub package_version: Version,
pub package_version: ConcreteFunctionVersion,

/// The range that links this task back to the source text.
pub range: TextRange,
Expand All @@ -395,7 +395,7 @@ impl From<&TaskState> for FunctionEntry {
params: vec![],

package_name: Some(value.package_name.clone()),
package_version: Some(value.package_version),
package_version: Some(value.package_version.clone()),
class_name: None,

arg_names: value.arg_names.clone(),
Expand Down Expand Up @@ -441,7 +441,7 @@ pub struct ClassState {
/// If this class is imported from a package, then the package's name is stored here.
pub package_name: Option<String>,
/// If this class is imported from a package, then the package's version is stored here.
pub package_version: Option<Version>,
pub package_version: Option<ConcreteFunctionVersion>,

/// The range that links this class back to the source text.
pub range: TextRange,
Expand Down Expand Up @@ -526,7 +526,7 @@ impl ClassState {
symbol_table: c_table,

package_name: self.package_name.clone(),
package_version: self.package_version,
package_version: self.package_version.clone(),

index: usize::MAX,

Expand Down
4 changes: 2 additions & 2 deletions brane-ast/src/traversals/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn move_task(task: &Rc<RefCell<FunctionEntry>>, table: &mut TableState) {
requirements: entry.requirements.clone().unwrap(),

package_name: entry.package_name.clone().unwrap(),
package_version: entry.package_version.unwrap(),
package_version: entry.package_version.clone().unwrap(),
Comment thread
DanielVoogsgerd marked this conversation as resolved.

range: entry.range.clone(),
}
Expand Down Expand Up @@ -240,7 +240,7 @@ fn move_class(class: &Rc<RefCell<ClassEntry>>, table: &mut TableState) -> Result
methods,

package_name: entry.package_name.clone(),
package_version: entry.package_version,
package_version: entry.package_version.clone(),

range: entry.range.clone(),
}
Expand Down
8 changes: 6 additions & 2 deletions brane-ast/src/traversals/print/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@
"{}Task<Compute> {}{}::{}({}){};",
indent!(indent),
def.package,
if !def.version.is_latest() { format!("<{}>", def.version) } else { String::new() },
// FIXME: Removed latest alias

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
// if let AliasedFunctionVersion::Version(semver) = &def.version { format!("<{}>", semver) } else { String::new() },
format_args!("<{}>", &def.version),
&def.function.name,
def.function.args.iter().enumerate().map(|(i, a)| format!("{}: {}", def.args_names[i], a)).collect::<Vec<String>>().join(", "),
if def.function.ret != DataType::Void { format!(" -> {}", def.function.ret) } else { String::new() },
Expand Down Expand Up @@ -195,7 +197,9 @@
TaskDef::Compute(def) => format!(
"{}{}::{}",
def.package,
if !def.version.is_latest() { format!("<{}>", def.version) } else { String::new() },
// FIXME:: Removed latest

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
// if let AliasedFunctionVersion::Version(semver) = &def.version { format!("<{}>", semver) } else { String::new() },
format_args!("<{}>", &def.version),
def.function.name
),
TaskDef::Transfer => "__builtin::transfer".into(),
Expand Down
20 changes: 13 additions & 7 deletions brane-ast/src/traversals/print/ast_unresolved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@
"{}Task<Compute> {}{}::{}({}){};",
indent!(indent),
t.package_name,
if !t.package_version.is_latest() { format!("<{}>", t.package_version) } else { String::new() },
// FIXME: Removed latest

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
// if let AliasedFunctionVersion::Version(semver) = &t.package_version { format!("<{semver}>") } else { String::new() },
format_args!("<{:?}>", &t.package_version),
&t.name,
t.signature.args.iter().enumerate().map(|(i, a)| format!("{}: {}", t.arg_names[i], a)).collect::<Vec<String>>().join(", "),
if t.signature.ret != DataType::Void { format!(" -> {}", t.signature.ret) } else { String::new() },
Expand All @@ -105,11 +107,13 @@
format!(
"{}{}::",
package,
if !c.package_version.as_ref().unwrap().is_latest() {
format!("<{}>", c.package_version.as_ref().unwrap())
} else {
String::new()
}
// FIXME: Unnecessary unwrap (probably)

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
// if let AliasedFunctionVersion::Version(semver) = &c.package_version.as_ref().unwrap() {
// format!("<{semver}>")
// } else {
// String::new()
// }
format_args!("<{:?}>", &c.package_version),
)
} else {
String::new()
Expand Down Expand Up @@ -338,7 +342,9 @@
let task: String = format!(
"{}{}::{}",
task.package_name,
if !task.package_version.is_latest() { format!("<{}>", task.package_version) } else { String::new() },
// FIXME: Removed latest

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
// if let AliasedFunctionVersion::Version(semver) = &task.package_version { format!("<{semver}>") } else { String::new() },
format_args!("<{}>", &task.package_version),
task.name
);

Expand Down
Loading
Loading