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

Add basic actions.yaml and notebook support #1595

Merged
merged 9 commits into from
Dec 4, 2023

Conversation

Ekrekr
Copy link
Contributor

@Ekrekr Ekrekr commented Nov 29, 2023

No description provided.

core/compilers.ts Show resolved Hide resolved
@Ekrekr Ekrekr requested a review from BenBirt November 30, 2023 11:03
@Ekrekr Ekrekr requested review from tatianaschmidt and GJMcGowan and removed request for BenBirt and tatianaschmidt December 1, 2023 14:36
@Ekrekr Ekrekr requested a review from BenBirt December 1, 2023 14:53
Copy link
Collaborator

@GJMcGowan GJMcGowan left a comment

Choose a reason for hiding this comment

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

yuge

import { dataform } from "df/protos/ts";

/**
* @hidden
Copy link
Collaborator

Choose a reason for hiding this comment

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

This? https://typedoc.org/tags/hidden

So your intention is to hide the class from docs until you're ready, is that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't expose these action classes anyways, because users don't access them directly

export class Table {

core/main.ts Outdated
function loadActionConfigs(session: Session, filePaths: string[]) {
filePaths
.filter(path => path.startsWith(`definitions${utils.pathSeperator}`))
.filter(path => path.endsWith("actions.yaml"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why two filters instead of path.startsWith && path.endsWith?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@Ekrekr Ekrekr merged commit a0d4c69 into main_v3 Dec 4, 2023
4 checks passed
@Ekrekr Ekrekr deleted the add-basic-actions-yaml-notebook-support branch December 4, 2023 10:28
this.proto.config = config;
}

public setNotebookContents(contents: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this doesn't follow the pattern in other action classes, which do not have setX(...), instead just x(...). i don't have a strong opinion on which style we should use (lewis probably does), but i think we should at least have a consistent API, because this is a public API.

if (path.endsWith(".ipynb")) {
const notebookAsJson = JSON.parse(code);
// TODO(ekrekr): strip notebook cell outputs.
// TODO(ekrekr): base64 encode the notebook as a string instead.
Copy link
Collaborator

Choose a reason for hiding this comment

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

why?

function loadActionConfigs(session: Session, filePaths: string[]) {
filePaths
.filter(
path => path.startsWith(`definitions${utils.pathSeperator}`) && path.endsWith("actions.yaml")
Copy link
Collaborator

Choose a reason for hiding this comment

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

this isn't really the spec that was agreed upon - actions.yaml should have a path separator before it

function loadActionConfigs(session: Session, filePaths: string[]) {
filePaths
.filter(
path => path.startsWith(`definitions${utils.pathSeperator}`) && path.endsWith("actions.yaml")
Copy link
Collaborator

Choose a reason for hiding this comment

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

please fix seperator to separator?

Comment on lines +130 to +135
if (!actionConfig.target?.name) {
if (!actionConfig.target) {
actionConfig.target = {};
}
actionConfig.target.name = fileNameAsTargetName;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO this would be clearer as:

if (!actionConfig.target) {
  actionConfig.target = {};
}
if (!actionConfig.target.name) {
  actionConfig.target.name = fileNameAsTargetName;
}

});
}

function extractActionDetailsFromFileName(
Copy link
Collaborator

Choose a reason for hiding this comment

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

this feels very related to a lot of stuff in utils.ts, and should probably be there

): { fileExtension: string; fileNameAsTargetName: string } {
// TODO(ekrekr): make filename in actions.yaml files not need the `definitions` prefix. In
// addition, actions.yaml in nested directories should prefix file imports with their path.
const fileName = path.split("/").slice(-1)[0];
Copy link
Collaborator

Choose a reason for hiding this comment

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

bug: should be using separator

@@ -193,6 +195,14 @@ export class Session {
}
}

public notebookAction(notebookConfig: dataform.ActionConfig, notebookContents: string): Notebook {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is part of our public API, and should follow that consistently, i.e. notebook()

Comment on lines +189 to +192
if (action.config) {
action.config.target = target(session.canonicalConfig, name, overrideSchema, overrideDatabase);
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

i'm confused. why do we need this / what's it for / should it really be here, as opposed to the callsite?

moker-spaghetti pushed a commit to moker-spaghetti/dataform that referenced this pull request May 26, 2024
* Add basic actions.yaml and notebook support

* Add test for notebook

* Add action details extraction from filename, facilitate requiring notebooks, make tests work

* Tidy

* Fix lint errors

* fix

* George comments
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.

None yet

3 participants