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 cli entrypoint for compile #218

Merged
merged 10 commits into from
Jun 22, 2023
Merged

Add cli entrypoint for compile #218

merged 10 commits into from
Jun 22, 2023

Conversation

GeorgesLorre
Copy link
Collaborator

WIP!

First implementation of the fondant CLI (tried and tested):

fondant compile -p /playground/mycoolpipeline.py:pipeline

(note you will need to (re)run poetry install --all-extras)

I'm mainly looking for feedback on this approach before I spend more time expanding it

fondant/cli.py Outdated
from fondant.pipeline import Pipeline


class PipelinePythonReference(argparse.Action):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did not find anything standard on importstrings (file.py:my_object) so I made my own parser.

Copy link
Member

Choose a reason for hiding this comment

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

Any reason to go for a custom Action instead of a custom type? I think a custom type could be a bit simpler.

FYI, reference implementation from uvicorn.

fondant/cli.py Outdated
"""Attempt to load a pipeline from a module file path and object name."""
spec = importlib.util.spec_from_file_location(object, module)
pipeline = importlib.util.module_from_spec(spec) # type: ignore
spec.loader.exec_module(pipeline) # type: ignore
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not that happy with this mess but works for now

Copy link
Member

Choose a reason for hiding this comment

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

See my comment above for an implementation based on import_module and getattr.

Base automatically changed from feature/local-starcoder to main June 20, 2023 12:56
Copy link
Member

@RobbeSneyders RobbeSneyders left a comment

Choose a reason for hiding this comment

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

Thanks @GeorgesLorre! I know it must hurt to see the coverage decline, but looking at the uncovered lines, I don't think there's a lot to test without just duplicating the same logic.

@@ -1,5 +1,6 @@
"""Pipeline used to create the dataset to train the StarCoder model."""

import argparse
Copy link
Member

Choose a reason for hiding this comment

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

Why was this added? I think we should be able to remove the if __name__ = "__main__": block at the bottom of the file, no?

Comment on lines 132 to 136
# add component spec to command if does not exist yet
if not component_op.arguments.get("component_spec"):
component_spec = component_op.component_spec.specification
command.extend(["--component_spec", json.dumps(component_spec)])

Copy link
Member

Choose a reason for hiding this comment

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

You added this to the ComponentOp class in #215, right?

Copy link
Member

@RobbeSneyders RobbeSneyders left a comment

Choose a reason for hiding this comment

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

One more thing 😉

Copy link
Member

Choose a reason for hiding this comment

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

This should be left out of git.

@GeorgesLorre GeorgesLorre marked this pull request as ready for review June 22, 2023 07:46
Copy link
Member

@RobbeSneyders RobbeSneyders left a comment

Choose a reason for hiding this comment

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

Thanks!

@GeorgesLorre GeorgesLorre merged commit 3e47ef7 into main Jun 22, 2023
@GeorgesLorre GeorgesLorre deleted the feature/fondant-cli branch June 22, 2023 07:53
Hakimovich99 pushed a commit that referenced this pull request Oct 16, 2023
WIP!

First implementation of the fondant CLI (tried and tested):

`fondant compile -p /playground/mycoolpipeline.py:pipeline`

(note you will need to (re)run `poetry install --all-extras`)

I'm mainly looking for feedback on this approach before I spend more
time expanding it
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.

2 participants