Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert vis-type to visType at parse time #393

Merged
merged 5 commits into from
Jun 13, 2024
Merged

convert vis-type to visType at parse time #393

merged 5 commits into from
Jun 13, 2024

Conversation

interim17
Copy link
Contributor

Time Estimate or Size

small

Problem

There were todo comments in the code about converting the ["vis-type]" key in AgentData to visType

Solution

Added checks in parsing functions to output visType properties when incoming data has vis-type properties. Trajectories are running and tests are passing.

  • Bug fix (non-breaking change which fixes an issue)

Copy link

github-actions bot commented Jun 4, 2024

jest coverage report 🧪

Total coverage

Status Category Percentage Covered / Total
🔴 Statements 40.97% 2042/4983
🔴 Branches 43.21% 838/1939
🔴 Functions 36.99% 418/1130
🔴 Lines 41.2% 1955/4745

Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold

@interim17 interim17 marked this pull request as ready for review June 4, 2024 16:24
@interim17 interim17 requested a review from a team as a code owner June 4, 2024 16:24
@interim17 interim17 requested review from meganrm, frasercl and toloudis and removed request for a team and frasercl June 4, 2024 16:24
@@ -63,7 +62,9 @@ class VisData {
};

for (let k = 0; k < AGENT_OBJECT_KEYS.length; ++k) {
agentData[AGENT_OBJECT_KEYS[k]] = floatView[j++];
const key = AGENT_OBJECT_KEYS[k];
const targetKey = key === "vis-type" ? "visType" : key;
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: does simulariumio output vis-type anymore? Will we ever see data with this key name? I am sort of hoping we can remove it forever. Also I suggest putting the if key is vis-type then rename it to visType into a single function so that vis-type is not repeated in more than one place. The function can have a pointed name like fixLegacyBadAgentPropertyName or something...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ascibisz what do you think about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Simulariumio doesn't output anything with vis-type or visType in it, as it doesn't set key names in that part of the data at all, the type of data each number represents is assumed based on its position. So as long as all references to vis-type are changed to visType within this repo, you should be fine. I don't see any references to vis-type anywhere else.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, so even when we stream a json trajectory, the agent data is just in an ordered array of numbers without key names..? Which means we can totally replace "vis-type" throughout this code!

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct! I will change that line of code, to be safe, although it's not currently getting called anywhere in Octopus

@@ -154,7 +154,6 @@ export interface FileReturn {

// IMPORTANT: Order of this array needs to perfectly match the incoming data.
export const AGENT_OBJECT_KEYS = [
// TODO: convert "vis-type" to visType at parse time
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this key still needs some sort of comment here about how this is for json data coming from the server? or maybe not. Does octopus send json data out?

Copy link
Contributor

@toloudis toloudis left a comment

Choose a reason for hiding this comment

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

Thanks for making this change. Looks like all uses of "vis-type" can just disappear forever now ...?

@interim17
Copy link
Contributor Author

Thanks for making this change. Looks like all uses of "vis-type" can just disappear forever now ...?

Yes, done!

@@ -154,7 +154,6 @@ export interface FileReturn {

// IMPORTANT: Order of this array needs to perfectly match the incoming data.
export const AGENT_OBJECT_KEYS = [
// TODO: convert "vis-type" to visType at parse time
"vis-type",
Copy link
Contributor

@toloudis toloudis Jun 13, 2024

Choose a reason for hiding this comment

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

can this line go away now too - or change to visType?

@interim17 interim17 merged commit 61a8591 into main Jun 13, 2024
6 checks passed
@interim17 interim17 deleted the feature/vistype branch June 13, 2024 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants