Skip to content

feat(actualV1): Actual Launch! Symbolic v1! Let's GOOOO!#19

Merged
DanielSeehausen merged 17 commits into
mainfrom
finishing-touches-for-initial-deploy
Jun 16, 2021
Merged

feat(actualV1): Actual Launch! Symbolic v1! Let's GOOOO!#19
DanielSeehausen merged 17 commits into
mainfrom
finishing-touches-for-initial-deploy

Conversation

@DanielSeehausen
Copy link
Copy Markdown
Contributor

BREAKING CHANGE: breaks the fake major version!

image

Ignore the diff! please review the code from /src.

I can best recommend reading the README since that attempts to outline the major architecture and will make looking at the code a lot more straight forward I believe.

My goal while writing this was EXtenSIbiliTy so I would particularly appreciate any feedback regarding that. I wanted it to be open for UNCLE extension and closed for BOB modification. E.g.

  • easy to add new complex fcts by following the pattern provided
  • hard to circumvent the SCHEMA structures
  • easy to test
  • hard to mutate anything that would fail data validation
  • easy to get to/from JSON.

closes ospin-web-dev/REACTor#1329

DanielSeehausen and others added 7 commits June 10, 2021 18:35
* moves seeder from test to src directory

* exports the seeders and the datastream from the package index.js

Co-authored-by: Viktor Diezel <viktor.diezel@ospin.de>
@DanielSeehausen DanielSeehausen force-pushed the finishing-touches-for-initial-deploy branch from 31ad621 to fbb7997 Compare June 10, 2021 17:08
Comment thread src/slots/Slot.js Outdated
}
}

static get UNITLESS_UNIT() { return Slot.UNIT_TYPE_UNIT_OPTIONS.unitless[0] }
Copy link
Copy Markdown
Contributor

@vdiezel vdiezel Jun 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are implicitly using the "magic string" unitless. A safer options would be

Slot.UNIT_TYPE_UNIT_OPTIONS[Slot.UNIT_TYPES.UNITLESS][0]

Or write a helper method if that is too ugly:

static getUnitOptionsFromUnitType(type) {
  return Slot.UNIT_TYPE_UNIT_OPTIONS[type]
}

const unitLessUnit = Slot.getUnitOptionsFromUnitType(Slot.UNIT_TYPES.UNITLESS)[0]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v good 👁️ ! updated

Comment thread src/slots/Slot.js
Comment on lines +89 to +96
if (
this.unit !== otherSlot.unit
&& !this.isUnitless()
&& !otherSlot.isUnitless()
) {
throw new SlotConnectionError(this, otherSlot, 'units must match between slots')
}
}
Copy link
Copy Markdown
Contributor

@vdiezel vdiezel Jun 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I have one slot that is unitless and another one that is not, should they be compatible? If I'm not mistaken, this code says yes. Do we want that behaviour or should we treat unitless just as any other "unit" by saying: only unitless slots can be connected.

I see that we might be be missing the difference between: Allow any unit which might be required for certain customer made functionalities, like an "averager" functionality, and functionalities that allow only unitless input, like PID parameters.
Your solution covers the "averager" case: We don't know which units are going in, so we can't create the slots accordingly with the correct unit. It would also allow putting in non-sense values e.g. to the PID slots.
Maybe we should make a difference between unitless as - and null ? Or introduce a new string identifier, like any.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

screw that, total freedom!

vdiezel
vdiezel previously approved these changes Jun 11, 2021
Copy link
Copy Markdown
Contributor

@vdiezel vdiezel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very professional - very easy to read and the tests show how easy the interface is to use.
I have nothing to complain about - I think my only chance to contribute would be only after actually using it for a while.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 11, 2021

Codecov Report

Merging #19 (d284171) into main (26a3a16) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main       #19   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           25        27    +2     
  Lines          458       489   +31     
  Branches        32        30    -2     
=========================================
+ Hits           458       489   +31     
Impacted Files Coverage Δ
src/slots/InSlot.js 100.00% <ø> (ø)
src/slots/SlotConnectionError.js 100.00% <ø> (ø)
src/dataStreams/DataStream.js 100.00% <100.00%> (ø)
src/fctGraph/AddFunctionalityError.js 100.00% <100.00%> (ø)
src/fctGraph/FCTGraph.js 100.00% <100.00%> (ø)
src/functionalities/Functionality.js 100.00% <100.00%> (ø)
src/functionalities/index.js 100.00% <100.00%> (ø)
src/mixins/instanceMixins/JOIous.js 100.00% <100.00%> (ø)
src/slots/OutSlot.js 100.00% <100.00%> (ø)
src/slots/Slot.js 100.00% <100.00%> (ø)
... and 9 more

@DanielSeehausen DanielSeehausen force-pushed the finishing-touches-for-initial-deploy branch 6 times, most recently from e7db921 to 02bb9c8 Compare June 15, 2021 09:53
this.slots = Array.isArray(slots)
? slots.map(SlotFactory.new)
: []
this.slots = []
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall a best practice when initializing objects is to always provide everything the object will need in its lifecycle in the constructor (e.g., avoid doing things like adding a new this.property in some helper method because that makes the instance a lot less transparent). For this reason are empty slots added here, then immediately populated in the add slots call.


static deepEquals(objA, objB) {
const objDiff = this.diff(objA, objB)
const objDiff = this.diff(objA.serialize(), objB.serialize())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only the serialized results count as equality. Anything not communicated in serialization is internal to the fctgraph workings, and not persisted when it is sent/stored as JSON

Comment on lines +19 to +29
static generateSlots(functionalityId) {
if (!Array.isArray(this.SLOT_SEEDS)) {
throw new Error(`${this.name} must have .SLOT_SEEDS to use .generateSlots`)
}

return this.SLOT_SEEDS.map(slotData => ({
...slotData,
functionalityId,
}))
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is used now in all children of FunctionalitySeeder (e.g. TemperatureSensor) because they must send their functionality id to their slots!

@DanielSeehausen DanielSeehausen force-pushed the finishing-touches-for-initial-deploy branch from 02bb9c8 to fa13444 Compare June 15, 2021 10:02
Comment on lines +14 to +17
const fctData = {
...super.generate(overrideData),
subType: HeaterActuator.SUB_TYPE,
slots: [ ...this.SLOT_SEEDS ],
...data,
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first, do what is required to generate an id

Comment on lines +20 to +22
...fctData,
slots: [ ...this.generateSlots(overrideData.id || fctData.id) ],
...overrideData,
Copy link
Copy Markdown
Contributor Author

@DanielSeehausen DanielSeehausen Jun 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then use the id when making the slots (or use the provided id)

(the changes to this FCT seeder is recreated in all of the usable FCT seeders)

Comment thread src/slots/Slot.js
}

static get UNITLESS_UNIT() { return Slot.UNIT_TYPE_UNIT_OPTIONS.unitless[0] }
static get UNITLESS_UNIT() { return Slot.UNIT_TYPE_UNIT_OPTIONS[Slot.UNIT_TYPES.UNITLESS][0] }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requested change

@DanielSeehausen
Copy link
Copy Markdown
Contributor Author

ready for review!
fa13444
this is the only commit that needs review ^

FelixMZ2018
FelixMZ2018 previously approved these changes Jun 16, 2021
Copy link
Copy Markdown
Contributor

@FelixMZ2018 FelixMZ2018 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! The tests make it really easy to understand usage and concepts!
I left a few comments but nothing is blocking from my side

Comment thread README.md
[![codecov](https://codecov.io/gh/ospin-web-dev/FCTGraph/branch/master/graph/badge.svg)](https://codecov.io/gh/ospin-web-dev/FCTGraph)
[![Maintainability](https://api.codeclimate.com/v1/badges/ab083cc74a1fbb1d7319/maintainability)](https://codeclimate.com/repos/60ae147b04beeb018b015a77/maintainability)
[![codecov](https://codecov.io/gh/ospin-web-dev/FCTGraph/branch/main/graph/badge.svg?token=RXXLX0HDAR)](https://codecov.io/gh/ospin-web-dev/FCTGraph)
[![Maintainability](https://api.codeclimate.com/v1/badges/184840b3c795f19f837b/maintainability)](https://codeclimate.com/github/ospin-web-dev/FCTGraph/maintainability)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should codeclimate be removed here ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question - no because this is public (which codeclimate works on)

Comment thread test/mixins/instanceMixins/JOIous.test.js Outdated
Comment thread .github/workflows/release.yml Outdated
Comment thread package.json
"test-release": "npx semantic-release --dry-run",
"test": "jest",
"test-with-coverage": "jest -i --coverage",
"test-with-coverage": "jest --coverage",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth changing the script title in hambda so all 3 projects use the same syntax

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree

Comment thread package.json
@@ -24,7 +24,7 @@
"start": "node index.js",
"test-release": "npx semantic-release --dry-run",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think that would work because it can only be called from the master branch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this guy provides(ed) valuable information for testing releases!
image

return util.inspect(this, { compact: false, depth: 4 })
}

// deeper print outs while running on Node
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the deeper printout have a higher depth than 4 ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question and 👁️ ! - I actually chose 4 off the cuff assuming it would get us all the way down to data streams from an FCTGraph printout and no further. Turns out it doesn't (but 6 does!).

{ fctGraph: { fcts: { slots: { dataStreams } }

I have updated it (and also fixed unfound mistake in which datastreams weren't being serialized).

Co-authored-by: Felix Menzel <36296555+FelixMZ2018@users.noreply.github.com>
@DanielSeehausen DanielSeehausen force-pushed the finishing-touches-for-initial-deploy branch from 5945b3b to d284171 Compare June 16, 2021 10:23
@DanielSeehausen DanielSeehausen merged commit 9ac6788 into main Jun 16, 2021
@DanielSeehausen DanielSeehausen deleted the finishing-touches-for-initial-deploy branch June 16, 2021 10:58
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 2.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants