Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Fix flyio org option not working #662

Merged
merged 4 commits into from
May 10, 2023
Merged

Conversation

aminalaee
Copy link
Contributor

Subset of #661

@aminalaee aminalaee requested a review from a team April 26, 2023 11:49
@aminalaee aminalaee temporarily deployed to external April 26, 2023 11:49 — with GitHub Actions Inactive
@@ -110,6 +110,8 @@ def _create_app(self, state: FlyioAppState):
args["generate-name"] = True
if self.get_env().access_token:
args["access-token"] = self.get_env().access_token
if self.org:
args["org"] = self.org
Copy link
Contributor Author

@aminalaee aminalaee Apr 26, 2023

Choose a reason for hiding this comment

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

I couldn't find any tests for flyio

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point, looks like we didn't add them 👀

Copy link
Contributor

@aguschin aguschin Apr 27, 2023

Choose a reason for hiding this comment

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

Is this something you might be interested in? As a first step I think we should add a test for _create_app, asserting that resulting fly.toml looks right. This test can also help us pin down the root cause of #657

The second step would be to add a real e2e deploy to fly. I can create a test account there and set up GHA workflow to make it work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah sounds good. Do you want to add the tests in a separate PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, this PR is the right place :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aguschin Any idea how this can be tested?
I'm doing

def test_create_app():
    flyio_app = FlyioApp()
    state = flyio_app.get_state()
    flyio_app._create_app(state)

But the get_state() fails because of mlem.core.errors.MlemObjectNotSavedError: Not saved object has no location.
even if I create the app with a default state, while updating the state the issue happens again. I think I'm missing a step before the the call to create_app.

Copy link
Contributor

@aguschin aguschin May 1, 2023

Choose a reason for hiding this comment

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

Hi @aminalaee! Sure, let me help you out 🙌🏻
It needs to be dumped first:

from mlem.contrib.flyio.meta import FlyioApp


def test_create_app(tmpdir):
    flyio_app = FlyioApp()
    flyio_app.dump(str(tmpdir))
    state = flyio_app.get_state()
    flyio_app._create_app(state)

If you run this test, it will fail still (on the last line though), because creating flyio app requires Dockerfile present (...Could not find a Dockerfile, nor detect a runtime or framework from source code. Continuing with a blank app.\x1b).

Copy link
Contributor

Choose a reason for hiding this comment

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

You either need to bypass this, or maybe call mlem.api.deploy directly on flyio_app while mocking some actual deployment mechanisms. Then, until the temp dir with fly.toml and stuff is removed, you can read it in the test to make some checks. Hope that makes it clearer! If confused, please ping me, I'll help with that.

@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (bd230a2) 85.75% compared to head (dc3888d) 85.76%.

❗ Current head dc3888d differs from pull request most recent head 054ca10. Consider uploading reports for the commit 054ca10 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #662   +/-   ##
=======================================
  Coverage   85.75%   85.76%           
=======================================
  Files         109      109           
  Lines        9922     9924    +2     
=======================================
+ Hits         8509     8511    +2     
  Misses       1413     1413           
Impacted Files Coverage Δ
mlem/contrib/flyio/meta.py 45.29% <0.00%> (-0.79%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

aguschin

This comment was marked as resolved.

@aminalaee aminalaee temporarily deployed to external May 1, 2023 19:33 — with GitHub Actions Inactive
@aguschin
Copy link
Contributor

aguschin commented May 2, 2023

Hi @aminalaee! Overall, LGTM!

Two comments:

  1. I see FAILED tests/contrib/test_flyio.py::test_create_app - FileNotFoundError: [Errno 2] No such file or directory: 'flyctl' - we need to edit workflow to install flyctl and maybe even login with it - we need to see if running the test is possible without login
  2. Would be great to add a test that checks fly.toml content generated by flyctl (can be done in another PR though - we have mlem deploy flyio fails due to wrong fly.toml generated #657 about that).

@aminalaee
Copy link
Contributor Author

I will update the actions to install the flyctl cli.
But as for the login, in this test I have mocked the calls so that we don’t need credentials as we don’t call their API.

but this limits us for number 2 which adds an integration test. We can add another one.

@aguschin
Copy link
Contributor

Hi @aminalaee! How are you doing? Is everything ok? I tried to reach you out by email btw, but didn't get any answer.

@aguschin
Copy link
Contributor

Any help needed with this?

@aminalaee
Copy link
Contributor Author

Hey @aguschin
Sorry I'd missed the email and it was treated as spam (weird). I will check that now.

I was thinking to fix the pipeline in this PR with the current mocked tests and setup the integration tests in a separate PR?

@aguschin
Copy link
Contributor

Sure, this will work @aminalaee. Thanks!

@aguschin aguschin merged commit 1de0fc2 into iterative:main May 10, 2023
@aminalaee aminalaee deleted the fix-flyio-org branch May 10, 2023 18:45
@aminalaee aminalaee requested a deployment to external June 9, 2023 13:35 — with GitHub Actions Abandoned
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants