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

[risk=low][no ticket] Logic changes for runtime cost display #8980

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jmthibault79
Copy link
Collaborator

@jmthibault79 jmthibault79 commented Dec 3, 2024

Attempt to simplify the runtime UI code and logic a bit - part 1 of many.

Rename "detached" disk references to "persistent" which better reflects our use
Make arguments to cost functions more explicit about what they need
Reduce usage of AnalysisConfig and DiskConfig

Tested locally


PR checklist

  • I have included an issue ID or "no ticket" in the PR title as outlined in CONTRIBUTING.md.
  • I have included a risk tag of the form [risk=no|low|moderate|severe] in the PR title as outlined in CONTRIBUTING.md.
  • I have manually tested this change and my testing process is described above.
  • This change includes appropriate automated tests, and I have documented any behavior that cannot be tested with code.
  • I have added explanatory comments where the logic is not obvious.
  • One or more of the following is true:
    • This change is intended to complete a JIRA story, so I have checked that all AC are met for that story.
    • This change fixes a bug, so I have ensured the steps to reproduce are in the Jira ticket or provided above.
    • This change impacts deployment safety (e.g. removing/altering APIs which are in use), so I have documented the impacts in the description.
    • This change includes a new feature flag, so I have created and linked new JIRA tickets to (a) turn on the feature flag and (b) remove it later.
    • This change modifies the UI, so I have taken screenshots or recordings of the new behavior and notified the PO and UX designer in Slack.
    • This change modifies API behavior, so I have run the relevant E2E tests locally because API changes are not covered by our PR checks.
    • None of the above apply to this change.

@@ -76,11 +94,9 @@ export const EnvironmentCostEstimator = ({
...styles.cost,
color: costTextColor,
};
const pdCost = cond(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is a good illustration of the complexity around how AnalysisConfig represents Persistent Disks.

  • if the diskConfig indicates that the disk is detachable, then the diskConfig represents a PD
  • else: the diskConfig represents a standard (non-persistent, non-detachable) disk
  • there may also be a detachedDisk. If so, that one is a persistent disk

My intention is to move the distinction between "detached" vs. otherwise to "persistent" vs. otherwise, which better reflects how we think about them today.

see the new derivePdFromAnalysisConfig() which captures this logic.

const { computeType, gpuConfig, machine, numNodes, dataprocConfig } =
analysisConfig;

// temp derive from analysisConfig
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

my eventual goal is to stop using AnalysisConfig, but that's going to take some time

export const diskPrice = diskPricePerMonth / approxHoursPerMonth; // per GB hour, from https://cloud.google.com/compute/pricing
export const ssdPricePerMonth = 0.17; // per GB month
export const dataprocCpuPrice = 0.01; // dataproc costs $0.01 per cpu per hour
const standardDiskPricePerMonth = 0.04; // per GB month, from https://cloud.google.com/compute/pricing
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

a lot of renaming and rearranging here to better explain what these values mean and what the functions are doing


const dataprocSurcharge = ({
interface DataprocSurcharge {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

be more explicit about what these functions need

return fp.sum([
diskConfigPrice(diskConfig),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These two lines cover the same costs but in different ways.

before:

  • L433 was the cost of the "main disk" of the runtime: the GCE PD or the DataProc Master
  • L434 was the cost of any detached PD if one exists

after:

  • L466 is the cost of the PD, whether attached (to GCE) or not
  • L467 is the cost of the DataProc Master node disk, if it exists

@@ -184,9 +184,15 @@ export const withAnalysisConfigDefaults = (
dataprocConfig = {
numberOfWorkers:
dataprocConfig?.numberOfWorkers ?? defaults.numberOfWorkers,
masterMachineType:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

previously, this did not set defaults for some fields. There was no clear reason for skipping these, and we do have defaults we can use for all of them. By adding them, we can simplify some logic.

@@ -813,19 +813,11 @@ describe(withAnalysisConfigDefaults.name, () => {
existingDiskName: null,
};

// yes it removes 3 fields. why?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed this discrepancy

@@ -839,48 +831,19 @@ describe(withAnalysisConfigDefaults.name, () => {
);
});

const replaceableFields = [
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

all fields are now "replaceable" so we don't need this special logic

@@ -346,9 +346,15 @@ export const CustomizePanel = ({
gcePersistentDisk
);

const dataprocConfig = analysisConfig.dataprocConfig && {
...analysisConfig.dataprocConfig,
masterDiskSize: diskConfig.size,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it was always correct to set this, but it was not needed because it's also captured in diskConfig. Now we need this because we use this value to calculate costs.

@jmthibault79 jmthibault79 marked this pull request as ready for review December 3, 2024 21:42
@jmthibault79 jmthibault79 changed the title Joel/runtime UI [risk=low][no ticket] Logic changes for runtime cost display Dec 3, 2024
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.

1 participant