-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor the DNA Properties and how Applet Configurations are Created to Allow Adding of Additional Configs from Wizard #21
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, all tests pass.
|
||
#[hdk_extern] | ||
pub fn init(_: ()) -> ExternResult<InitCallbackResult> { | ||
let prop = Properties::get()?; | ||
let my_key = agent_info()?.agent_latest_pubkey; | ||
if let false = Properties::is_community_activator(my_key)? { | ||
if let false = Properties::is_community_activator(my_key.clone())? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename this variable "false" to something more in line with the check you are doing, like is_community_activator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh if let
is actually a rust sugar syntax for handling conditional statements and false
is actually one of the possible values of the statement on the right Properties::is_community_activator
.
If it is confusing, I could use a normal conditional statement handling instead @julioholon
We should consolidate applet config registration (#18) with adding additional config, or clearly distinguish the difference between these two processes. The idea with #18 is when a member adds an applet to the NH, the applet will need to register sensemaker types (dimension, methods, contexts, etc.) that it depends on to be able to function properly. Th differences I see between
I assume that It would be nice to be able to "intersect" these types like in TS, for example:
And for indexing, a sensemaker config is linked off the CA pub key, whereas applet config is uses a path like |
.dimensions | ||
.clone() | ||
.into_iter() | ||
.map(|dimension: Dimension| create_entry(&EntryTypes::Dimension(dimension))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of using create_entry
directly, it would be better to use create_dimension
and the other create_{sensemaker_type}
functions, so that if we want to change how these entries are indexed we only have to change it in one spot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes definitely. Thanks for pointing me to it. Will use that instead :D
@tatssato I added ts definitions of config related types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having a bunch of AppletConfigs that can be merged into a full SenseMakerConfig makes sense, and it also makes sense to store what changes each applet made to the config, so it can be "undone" sif the NH CA decides to remove that Applet.
name: string, | ||
// pub ranges: Array<Range>, // leaving out ranges since this is not an entry and is just part of the dimension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was so they could be fetched (separately from a dimension) as well as reused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup exactly what @weswalla said. I will be working on this in a separate PR including other recommendations Damien had :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weswalla Thanks. Got it. Will merge the beta-rc.2 to this branch :D
I'm not sure if it makes sense actually to have one full sensemaker config object that has to get updated everytime a new applet is added, as handling updates to an entry can be tricky and branches (of an update tree) can occur. If a UI wants a singular master config object, that can simply be a derived object (constructed in the zome function). I think what is most important is that we can fetch all sensemaker related objects (ranges, dimensions, methods, contexts, etc.) and know where they came from (an applet, or directly configured to the sensemaker by the CA). We can use links to accomplish this, which I think is sufficient for our use-cases. |
@weswalla @julioholon Tests are passing locally, but CI tests are failing as mentioned by @weswalla here P.S. I already merged the Here are some notes Changes
New validations requried (will include this in the PR including the changes from damien's reviews)
Let me know if any of you have any questions :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
I would say ready to merge, but after we merge in the other PR #22
use sensemaker_integrity::{LinkTypes, Properties, SensemakerConfig}; | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct UpdateConfigurtionInput { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: UpdateConfigurtionInput
-> UpdateConfigurationInput
// for each config, check the format and creat the config entries with the helper function | ||
for config in prop.applet_configs { | ||
config.clone().check_format()?; | ||
create_entries_from_applet_config(config)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so I see that you've consolidated the process of adding config items (resource types, ranges, dimensions, methods, etc.) into the AppletConfig
type. I don't see any issues with this approach, however, it makes me think about to what extent do we want to distinguish config specifically added because of installing an applet (registering an applet) vs generic config added by the CA either at sensemaker spawning or sometime afterwards that is not for any specific applet.
Perhaps we would use a keyword as a applet name when adding config not from applet registration, which could be wrapped in a new zome function add_sensemaker_config
, when a CA wants to, for example, add new dimension. Or something like that. I don't think these are critical, blocking questions right now, but how we answer them will affect how we index/access data from the sensemaker to display in the dashboard.
@tatssato merged in develop branch which had been updated with the beta-rc.2 branch, CI should pass, and also updated some type definitions and got rid of |
This pr exposes
add_config
zome function which takes in additional sensemaker config (same format) and creates necessary entries out of that config.get_configs
zome function is also exposed to allow anyone in the neighborhood to read existing configurations.