Skip to content

Commit

Permalink
Merge pull request #73 from azriel91/feature/35/profile-show
Browse files Browse the repository at this point in the history
  • Loading branch information
azriel91 authored Jan 20, 2023
2 parents 696be70 + 4a5534d commit 162cd13
Show file tree
Hide file tree
Showing 67 changed files with 1,455 additions and 1,031 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: 'Install `wasm-pack`'
uses: jetli/[email protected]
with:
version: 'latest'
version: 'v0.10.3'

- name: mdbook-graphviz Cache
id: mdbook_graphviz_cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ jobs:
- name: 'Install `wasm-pack`'
uses: jetli/[email protected]
with:
version: 'latest'
version: 'v0.10.3'

- name: 'Build examples'
run: |
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* Support progress bars in `CliOutput`. ([#42], [#66])
* Consolidate `StateLogical` and `StatePhysical` into `ItemSpec::State`. ([#69], [#70])
* Use [ETag] to determine if a file needs to be re-downloaded. ([#68], [#71])
* Add `PeaceAppDir` layer so different Peace tools don't conflict with each other. ([#35], [#72])
* Move `profile` and `flow_id` parameters to `CmdContextBuilder`. ([#35], [#73])
* Support reading `Profile` from workspace params. ([#35], [#73])

[ETag]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
[#62]: https://github.com/azriel91/peace/pull/62
Expand All @@ -19,6 +22,9 @@
[#70]: https://github.com/azriel91/peace/pull/70
[#68]: https://github.com/azriel91/peace/issues/68
[#71]: https://github.com/azriel91/peace/pull/71
[#35]: https://github.com/azriel91/peace/issues/35
[#72]: https://github.com/azriel91/peace/pull/72
[#73]: https://github.com/azriel91/peace/pull/73


## 0.0.5 (2022-12-18)
Expand Down
3 changes: 2 additions & 1 deletion crate/resources/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
//! framework). There may be breakage between releases.
pub use self::{
flow_params_file::FlowParamsFile, op_check_statuses::OpCheckStatuses,
cmd_dirs::CmdDirs, flow_params_file::FlowParamsFile, op_check_statuses::OpCheckStatuses,
profile_params_file::ProfileParamsFile, state_diffs_mut::StateDiffsMut, states_mut::StatesMut,
workspace_dirs::WorkspaceDirs, workspace_params_file::WorkspaceParamsFile,
};

mod cmd_dirs;
mod flow_params_file;
mod op_check_statuses;
mod profile_params_file;
Expand Down
58 changes: 58 additions & 0 deletions crate/resources/src/internal/cmd_dirs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
use crate::paths::{FlowDir, ProfileDir, ProfileHistoryDir};

/// Directories used during `peace` execution.
///
/// This type itself is not inserted into `Resources`, but each of the member
/// directories are individually inserted. This is created by
/// `CmdDirsBuilder` from either the `peace_rt_model` or
/// `peace_rt_model_web` crates.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CmdDirs {
/// Directory to store data for the current profile.
profile_dir: ProfileDir,
/// Directory to store profile executions' summaries.
profile_history_dir: ProfileHistoryDir,
/// Directory to store data for the current flow.
flow_dir: FlowDir,
}

impl CmdDirs {
/// Returns new `CmdDirs`.
pub fn new(
profile_dir: ProfileDir,
profile_history_dir: ProfileHistoryDir,
flow_dir: FlowDir,
) -> Self {
Self {
profile_dir,
profile_history_dir,
flow_dir,
}
}

/// Returns the individual command directories.
pub fn into_inner(self) -> (ProfileDir, ProfileHistoryDir, FlowDir) {
let Self {
profile_dir,
profile_history_dir,
flow_dir,
} = self;

(profile_dir, profile_history_dir, flow_dir)
}

/// Returns a reference to the profile directory.
pub fn profile_dir(&self) -> &ProfileDir {
&self.profile_dir
}

/// Returns a reference to the profile history directory.
pub fn profile_history_dir(&self) -> &ProfileHistoryDir {
&self.profile_history_dir
}

/// Returns a reference to the flow directory.
pub fn flow_dir(&self) -> &FlowDir {
&self.flow_dir
}
}
52 changes: 3 additions & 49 deletions crate/resources/src/internal/workspace_dirs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::paths::{FlowDir, PeaceAppDir, PeaceDir, ProfileDir, ProfileHistoryDir, WorkspaceDir};
use crate::paths::{PeaceAppDir, PeaceDir, WorkspaceDir};

/// Directories used during `peace` execution.
///
Expand All @@ -14,12 +14,6 @@ pub struct WorkspaceDirs {
peace_dir: PeaceDir,
/// Peace app directory,
peace_app_dir: PeaceAppDir,
/// Directory to store data for the current profile.
profile_dir: ProfileDir,
/// Directory to store profile executions' summaries.
profile_history_dir: ProfileHistoryDir,
/// Directory to store data for the current flow.
flow_dir: FlowDir,
}

impl WorkspaceDirs {
Expand All @@ -28,48 +22,23 @@ impl WorkspaceDirs {
workspace_dir: WorkspaceDir,
peace_dir: PeaceDir,
peace_app_dir: PeaceAppDir,
profile_dir: ProfileDir,
profile_history_dir: ProfileHistoryDir,
flow_dir: FlowDir,
) -> Self {
Self {
workspace_dir,
peace_dir,
peace_app_dir,
profile_dir,
profile_history_dir,
flow_dir,
}
}

/// Returns the individual workspace directories.
pub fn into_inner(
self,
) -> (
WorkspaceDir,
PeaceDir,
PeaceAppDir,
ProfileDir,
ProfileHistoryDir,
FlowDir,
) {
pub fn into_inner(self) -> (WorkspaceDir, PeaceDir, PeaceAppDir) {
let Self {
workspace_dir,
peace_dir,
peace_app_dir,
profile_dir,
profile_history_dir,
flow_dir,
} = self;

(
workspace_dir,
peace_dir,
peace_app_dir,
profile_dir,
profile_history_dir,
flow_dir,
)
(workspace_dir, peace_dir, peace_app_dir)
}

/// Returns a reference to the workspace directory.
Expand All @@ -86,19 +55,4 @@ impl WorkspaceDirs {
pub fn peace_app_dir(&self) -> &PeaceAppDir {
&self.peace_app_dir
}

/// Returns a reference to the profile directory.
pub fn profile_dir(&self) -> &ProfileDir {
&self.profile_dir
}

/// Returns a reference to the profile history directory.
pub fn profile_history_dir(&self) -> &ProfileHistoryDir {
&self.profile_history_dir
}

/// Returns a reference to the flow directory.
pub fn flow_dir(&self) -> &FlowDir {
&self.flow_dir
}
}
4 changes: 3 additions & 1 deletion crate/rt/src/cmds/clean_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use peace_resources::{
states::{StatesCleaned, StatesCleanedDry},
Resources,
};
use peace_rt_model::{output::OutputWrite, CmdContext, Error, FnRef, ItemSpecBoxed, ItemSpecGraph};
use peace_rt_model::{
cmd::CmdContext, output::OutputWrite, Error, FnRef, ItemSpecBoxed, ItemSpecGraph,
};

use crate::cmds::sub::StatesCurrentDiscoverCmd;

Expand Down
2 changes: 1 addition & 1 deletion crate/rt/src/cmds/diff_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use peace_resources::{
states::StateDiffs,
Resources,
};
use peace_rt_model::{output::OutputWrite, CmdContext, Error, ItemSpecGraph, StatesTypeRegs};
use peace_rt_model::{cmd::CmdContext, output::OutputWrite, Error, ItemSpecGraph, StatesTypeRegs};

use crate::cmds::sub::{StatesDesiredReadCmd, StatesSavedReadCmd};

Expand Down
3 changes: 2 additions & 1 deletion crate/rt/src/cmds/ensure_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use peace_resources::{
Resources,
};
use peace_rt_model::{
cmd::CmdContext,
outcomes::{ItemEnsureBoxed, ItemEnsurePartialBoxed},
output::OutputWrite,
CmdContext, Error, ItemSpecBoxed, ItemSpecGraph, ItemSpecRt, Storage,
Error, ItemSpecBoxed, ItemSpecGraph, ItemSpecRt, Storage,
};
use tokio::sync::{mpsc, mpsc::UnboundedSender};

Expand Down
2 changes: 1 addition & 1 deletion crate/rt/src/cmds/states_desired_display_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use peace_resources::{
resources::ts::{SetUp, WithStatesDesired},
Resources,
};
use peace_rt_model::{CmdContext, Error};
use peace_rt_model::{cmd::CmdContext, Error};
use peace_rt_model_core::output::OutputWrite;

use crate::cmds::sub::StatesDesiredReadCmd;
Expand Down
2 changes: 1 addition & 1 deletion crate/rt/src/cmds/states_discover_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use peace_resources::{
resources::ts::{SetUp, WithStatesCurrentAndDesired},
Resources,
};
use peace_rt_model::CmdContext;
use peace_rt_model::cmd::CmdContext;

use crate::cmds::sub::{StatesCurrentDiscoverCmd, StatesDesiredDiscoverCmd};

Expand Down
2 changes: 1 addition & 1 deletion crate/rt/src/cmds/states_saved_display_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use peace_resources::{
resources::ts::{SetUp, WithStatesSaved},
Resources,
};
use peace_rt_model::{CmdContext, Error};
use peace_rt_model::{cmd::CmdContext, Error};
use peace_rt_model_core::output::OutputWrite;

use crate::cmds::sub::StatesSavedReadCmd;
Expand Down
2 changes: 1 addition & 1 deletion crate/rt/src/cmds/sub/states_current_discover_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use peace_resources::{
states::{ts::Current, StatesCurrent},
Resources,
};
use peace_rt_model::{CmdContext, Error, ItemSpecGraph, Storage};
use peace_rt_model::{cmd::CmdContext, Error, ItemSpecGraph, Storage};

use crate::BUFFERED_FUTURES_MAX;

Expand Down
2 changes: 1 addition & 1 deletion crate/rt/src/cmds/sub/states_desired_discover_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use peace_resources::{
states::{ts::Desired, StatesDesired},
Resources,
};
use peace_rt_model::{CmdContext, Error, ItemSpecGraph, StatesSerializer, Storage};
use peace_rt_model::{cmd::CmdContext, Error, ItemSpecGraph, StatesSerializer, Storage};

use crate::BUFFERED_FUTURES_MAX;

Expand Down
2 changes: 1 addition & 1 deletion crate/rt/src/cmds/sub/states_desired_read_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use peace_resources::{
type_reg::untagged::{BoxDtDisplay, TypeReg},
Resources,
};
use peace_rt_model::{CmdContext, Error, StatesSerializer, Storage};
use peace_rt_model::{cmd::CmdContext, Error, StatesSerializer, Storage};

/// Reads [`StatesDesired`]s from storage.
#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion crate/rt/src/cmds/sub/states_saved_read_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use peace_resources::{
type_reg::untagged::{BoxDtDisplay, TypeReg},
Resources,
};
use peace_rt_model::{CmdContext, Error, StatesSerializer, Storage};
use peace_rt_model::{cmd::CmdContext, Error, StatesSerializer, Storage};

/// Reads [`StatesSaved`]s from storage.
#[derive(Debug)]
Expand Down
12 changes: 12 additions & 0 deletions crate/rt_model/src/cmd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//! Command related types.
pub use self::{
cmd_context::CmdContext, cmd_context_builder::CmdContextBuilder,
cmd_dirs_builder::CmdDirsBuilder,
};

pub mod ts;

mod cmd_context;
mod cmd_context_builder;
mod cmd_dirs_builder;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use std::marker::PhantomData;
use peace_resources::{resources::ts::SetUp, Resources};

use crate::{
cmd_context_builder::KeyUnknown, CmdContextBuilder, ItemSpecGraph, StatesTypeRegs, Workspace,
cmd::{cmd_context_builder::KeyUnknown, ts::CmdContextCommon, CmdContextBuilder},
ItemSpecGraph, StatesTypeRegs, Workspace,
};

/// Information needed to execute a command.
Expand Down Expand Up @@ -76,7 +77,7 @@ where
workspace: &'ctx Workspace,
item_spec_graph: &'ctx ItemSpecGraph<E>,
output: &'ctx mut O,
) -> CmdContextBuilder<'ctx, E, O, KeyUnknown, KeyUnknown, KeyUnknown> {
) -> CmdContextBuilder<'ctx, E, O, CmdContextCommon, KeyUnknown, KeyUnknown, KeyUnknown> {
CmdContextBuilder::new(workspace, item_spec_graph, output)
}
}
Expand Down
Loading

0 comments on commit 162cd13

Please sign in to comment.