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

[heft] Require a logging name for every operation #4469

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/heft/src/cli/HeftActionRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ function _getOrCreatePhaseOperation(
// Only create the operation. Dependencies are hooked up separately
operation = new Operation({
groupName: phase.phaseName,
name: `${phase.phaseName} phase`,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What is the appropriate name for a phase?

In the source code, there currently seem to be very few places that actually read the name or groupName.

Copy link
Contributor

Choose a reason for hiding this comment

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

A phase operation is setup work that runs before all tasks in the given phase, so it should indicate something about setup or initialization.

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently the phase operation is only used for performing the clean.

runner: new PhaseOperationRunner({ phase, internalHeftSession })
});
operations.set(key, operation);
Expand All @@ -472,6 +473,7 @@ function _getOrCreateTaskOperation(
if (!operation) {
operation = new Operation({
groupName: task.parentPhase.phaseName,
name: `${task.taskName} task`,
runner: new TaskOperationRunner({
internalHeftSession,
task
Expand Down
6 changes: 3 additions & 3 deletions common/reviews/api/operation-graph.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface IOperationExecutionOptions {
// @beta
export interface IOperationOptions {
groupName?: string | undefined;
name?: string | undefined;
name: string;
runner?: IOperationRunner | undefined;
weight?: number | undefined;
}
Expand Down Expand Up @@ -140,7 +140,7 @@ export interface IWatchLoopState {

// @beta
export class Operation implements IOperationStates {
constructor(options?: IOperationOptions);
constructor(options: IOperationOptions);
// (undocumented)
addDependency(dependency: Operation): void;
readonly consumers: Set<Operation>;
Expand All @@ -152,7 +152,7 @@ export class Operation implements IOperationStates {
_executeAsync(context: IExecuteOperationContext): Promise<OperationStatus>;
readonly groupName: string | undefined;
lastState: IOperationState | undefined;
readonly name: string | undefined;
readonly name: string;
// (undocumented)
reset(): void;
runner: IOperationRunner | undefined;
Expand Down
8 changes: 4 additions & 4 deletions libraries/operation-graph/src/Operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface IOperationOptions {
/**
* The name of this operation, for logging.
*/
name?: string | undefined;
name: string;

/**
* The group that this operation belongs to. Will be used for logging and duration tracking.
Expand Down Expand Up @@ -100,7 +100,7 @@ export class Operation implements IOperationStates {
/**
* The name of this operation, for logging.
*/
public readonly name: string | undefined;
public readonly name: string;

/**
* When the scheduler is ready to process this `Operation`, the `runner` implements the actual work of
Expand Down Expand Up @@ -173,11 +173,11 @@ export class Operation implements IOperationStates {
*/
private _runPending: boolean = true;

public constructor(options?: IOperationOptions) {
public constructor(options: IOperationOptions) {
this.groupName = options?.groupName;
this.runner = options?.runner;
this.weight = options?.weight || 1;
this.name = options?.name;
this.name = options.name;
}

public addDependency(dependency: Operation): void {
Expand Down
Loading