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

Lightening studio orchestrator #2931

Merged
merged 58 commits into from
Aug 28, 2024
Merged

Conversation

safoinme
Copy link
Contributor

Describe changes

I implemented/fixed _ to achieve _.

Pre-requisites

Please ensure you have done the following:

  • I have read the CONTRIBUTING.md document.
  • If my change requires a change to docs, I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • I have based my new branch on develop and the open PR is targeting develop. If your branch wasn't based on develop read Contribution guide on rebasing branch to develop.
  • If my changes require changes to the dashboard, these changes are communicated/requested.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Other (add details above)

Copy link
Contributor

coderabbitai bot commented Aug 14, 2024

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added internal To filter out internal PRs and issues enhancement New feature or request labels Aug 14, 2024
Copy link

gitguardian bot commented Aug 14, 2024

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
Once a secret has been leaked into a git repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Copy link
Contributor

NLP template updates in examples/e2e_nlp have been pushed.

Copy link
Contributor

@htahir1 htahir1 left a comment

Choose a reason for hiding this comment

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

Left many comments on docs first :-) Otherwise its great!

docs/book/component-guide/orchestrators/lightning.md Outdated Show resolved Hide resolved
docs/book/component-guide/orchestrators/lightning.md Outdated Show resolved Hide resolved
docs/book/component-guide/orchestrators/lightning.md Outdated Show resolved Hide resolved
docs/book/component-guide/orchestrators/lightning.md Outdated Show resolved Hide resolved
docs/book/component-guide/orchestrators/lightning.md Outdated Show resolved Hide resolved

### Lightning AI UI

Lightning AI provides its own UI where you can monitor and manage your running applications, including the pipelines orchestrated by ZenML.
Copy link
Contributor

Choose a reason for hiding this comment

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

screenshots?


```python
lightning_settings = LightningOrchestratorSettings(
machine_type="gpu",
Copy link
Contributor

Choose a reason for hiding this comment

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

give the list of options currently available?

Copy link
Contributor

@schustmi schustmi left a comment

Choose a reason for hiding this comment

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

Didn't have time to look into the core parts of the PR yet, so just a few initial comments for now

custom_validation_function=_validate_remote_components,
)

def _get_lightning_client(
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not get a lightning client, it sets lighning env variables

src/zenml/integrations/lightning/orchestrators/utils.py Outdated Show resolved Hide resolved
with tempfile.NamedTemporaryFile(
mode="w+b", delete=False, suffix=".tar.gz"
) as f:
code_archive.write_archive(f)

hash_ = hashlib.sha1() # nosec

f.seek(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this a bug with the hash computation before or why is this seek needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was suggested by claude auto-complete

Copy link
Contributor

Choose a reason for hiding this comment

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

That doesn't mean you shouldn't think about it or verify that it makes sense. In this case, the seeking already happens at the end of code_archive.write_archive() which means it's not necessary here.


Returns:
The path where to archived code is uploaded.
A tuple containing the temporary file path and the computed hash.
Copy link
Contributor

Choose a reason for hiding this comment

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

The second item of this tuple is not the computed hash, but instead a filename. I think returning two filenames is not intuitive at all what they're supposed to be.

As far as I can see, this function is used below and in the lightning orchestrator, which actually doesn't even use the hash.

I would suggest we just use

with tempfile.NamedTemporaryFile(
        mode="w+b", delete=False, suffix=".tar.gz"
    ) as f:
        code_archive.write_archive(f)

in the lightning orchestrator (and also in the function below), I don't think that's worth having in a separate helper function.

I still like your idea of extracting the hash computation though, maybe we can make this compute_file_hash(file) -> str?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's just doc string error later on i was also using the filename as second output

Copy link
Contributor

Choose a reason for hiding this comment

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

Still I think it would be nicer to have a helper function that computes just the hash of a file instead of having both the archive writing and hash computation combined in one function.
If we had a util function to compute just the file hash, we have other places in the code where we could reuse it.

If you still think that we should not duplicate this code

with tempfile.NamedTemporaryFile(
        mode="w+b", delete=False, suffix=".tar.gz"
    ) as f:
        code_archive.write_archive(f)

maybe we create a second helper function which is called write_archive_to_temporary_file(...) -> str which does this and returns the filename?

@htahir1
Copy link
Contributor

htahir1 commented Aug 26, 2024

@schustmi should we merge this to main and work on the fixes when @safoinme is back?

Copy link

socket-security bot commented Aug 26, 2024

No dependency changes detected. Learn more about Socket for GitHub ↗︎

👍 No dependency changes detected in pull request

@safoinme safoinme requested review from htahir1 and schustmi August 26, 2024 17:41
Copy link
Contributor

Images automagically compressed by Calibre's image-actions

Compression reduced images by 45.5%, saving 429.78 KB.

Filename Before After Improvement Visual comparison
docs/book/.gitbook/assets/lightning_studio_ui.png 241.31 KB 106.06 KB -56.0% View diff
docs/book/.gitbook/assets/lightning_studio_vscode.png 702.89 KB 408.37 KB -41.9% View diff

292 images did not require optimisation.

Update required: Update image-actions configuration to the latest version before 1/1/21. See README for instructions.

with tempfile.NamedTemporaryFile(
mode="w+b", delete=False, suffix=".tar.gz"
) as f:
code_archive.write_archive(f)

hash_ = hashlib.sha1() # nosec

f.seek(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

That doesn't mean you shouldn't think about it or verify that it makes sense. In this case, the seeking already happens at the end of code_archive.write_archive() which means it's not necessary here.


Returns:
The path where to archived code is uploaded.
A tuple containing the temporary file path and the computed hash.
Copy link
Contributor

Choose a reason for hiding this comment

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

Still I think it would be nicer to have a helper function that computes just the hash of a file instead of having both the archive writing and hash computation combined in one function.
If we had a util function to compute just the file hash, we have other places in the code where we could reuse it.

If you still think that we should not duplicate this code

with tempfile.NamedTemporaryFile(
        mode="w+b", delete=False, suffix=".tar.gz"
    ) as f:
        code_archive.write_archive(f)

maybe we create a second helper function which is called write_archive_to_temporary_file(...) -> str which does this and returns the filename?

DEPLOYMENT_ID_OPTION = "deployment_id"


class LightningOrchestratorEntrypointConfiguration:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this not inheriting and specifying the deployment ID again?

logger.info("Main studio started.")
logger.info("Uploading code to main studio the code path: %s", filename)
main_studio.upload_file(
"/teamspace/studios/this_studio/.lightning_studio/.studiorc",
Copy link
Contributor

Choose a reason for hiding this comment

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

I have not checked this, but there must be some overlap between this code and the code in the orchestrator (some commands that are run in the studio, ...). We should refactor this to use some common util functions in the future.

@schustmi schustmi merged commit 3b1e8ff into develop Aug 28, 2024
71 of 75 checks passed
@schustmi schustmi deleted the feature/lightening-studio-orchestrator branch August 28, 2024 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request internal To filter out internal PRs and issues run-slow-ci
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants