fxn 0.0.14__tar.gz → 0.0.16__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {fxn-0.0.14 → fxn-0.0.16}/PKG-INFO +20 -18
  2. {fxn-0.0.14 → fxn-0.0.16}/README.md +19 -17
  3. {fxn-0.0.14 → fxn-0.0.16}/fxn/api/predictor.py +8 -8
  4. {fxn-0.0.14 → fxn-0.0.16}/fxn/cli/predict.py +15 -8
  5. {fxn-0.0.14 → fxn-0.0.16}/fxn/version.py +1 -1
  6. {fxn-0.0.14 → fxn-0.0.16}/fxn.egg-info/PKG-INFO +20 -18
  7. {fxn-0.0.14 → fxn-0.0.16}/LICENSE +0 -0
  8. {fxn-0.0.14 → fxn-0.0.16}/fxn/__init__.py +0 -0
  9. {fxn-0.0.14 → fxn-0.0.16}/fxn/api/__init__.py +0 -0
  10. {fxn-0.0.14 → fxn-0.0.16}/fxn/api/api.py +0 -0
  11. {fxn-0.0.14 → fxn-0.0.16}/fxn/api/dtype.py +0 -0
  12. {fxn-0.0.14 → fxn-0.0.16}/fxn/api/environment.py +0 -0
  13. {fxn-0.0.14 → fxn-0.0.16}/fxn/api/prediction.py +0 -0
  14. {fxn-0.0.14 → fxn-0.0.16}/fxn/api/profile.py +0 -0
  15. {fxn-0.0.14 → fxn-0.0.16}/fxn/api/storage.py +0 -0
  16. {fxn-0.0.14 → fxn-0.0.16}/fxn/api/tag.py +0 -0
  17. {fxn-0.0.14 → fxn-0.0.16}/fxn/api/user.py +0 -0
  18. {fxn-0.0.14 → fxn-0.0.16}/fxn/api/value.py +0 -0
  19. {fxn-0.0.14 → fxn-0.0.16}/fxn/cli/__init__.py +0 -0
  20. {fxn-0.0.14 → fxn-0.0.16}/fxn/cli/auth.py +0 -0
  21. {fxn-0.0.14 → fxn-0.0.16}/fxn/cli/env.py +0 -0
  22. {fxn-0.0.14 → fxn-0.0.16}/fxn/cli/misc.py +0 -0
  23. {fxn-0.0.14 → fxn-0.0.16}/fxn/cli/predictors.py +0 -0
  24. {fxn-0.0.14 → fxn-0.0.16}/fxn/magic.py +0 -0
  25. {fxn-0.0.14 → fxn-0.0.16}/fxn.egg-info/SOURCES.txt +0 -0
  26. {fxn-0.0.14 → fxn-0.0.16}/fxn.egg-info/dependency_links.txt +0 -0
  27. {fxn-0.0.14 → fxn-0.0.16}/fxn.egg-info/entry_points.txt +0 -0
  28. {fxn-0.0.14 → fxn-0.0.16}/fxn.egg-info/requires.txt +0 -0
  29. {fxn-0.0.14 → fxn-0.0.16}/fxn.egg-info/top_level.txt +0 -0
  30. {fxn-0.0.14 → fxn-0.0.16}/setup.cfg +0 -0
  31. {fxn-0.0.14 → fxn-0.0.16}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fxn
3
- Version: 0.0.14
3
+ Version: 0.0.16
4
4
  Summary: Run on-device and cloud AI prediction functions in Python. Register at https://fxn.ai.
5
5
  Home-page: https://fxn.ai
6
6
  Author: NatML Inc.
@@ -27,33 +27,35 @@ Run AI prediction functions (a.k.a "predictors") in your Python apps. With Funct
27
27
  ## Installing Function
28
28
  Function is distributed on PyPi. This distribution contains both the Python client and the command line interface (CLI). To install, open a terminal and run the following command:
29
29
  ```sh
30
- pip install fxn
30
+ pip install --upgrade fxn
31
31
  ```
32
32
 
33
33
  > Note that Function requires Python 3.9+
34
34
 
35
- ## Signing in to Function
36
- Head over to [fxn.ai](https://fxn.ai) to create an account by logging in. Once you do, generate an access key:
37
-
38
- ![generate access key](https://raw.githubusercontent.com/fxnai/.github/main/access_key.gif)
39
-
40
- Now, let's login to the Function CLI with your access key. Open a terminal and run the following command:
41
- ```sh
42
- fxn auth login <ACCESS KEY>
35
+ ## Making a Prediction
36
+ Let's run the [`@samplefxn/stable-diffusion`](https://fxn.ai/@samplefxn/stable-diffusion) predictor which accepts a text `prompt` and generates a corresponding image.
37
+
38
+ ### In Python
39
+ Run the following Python script:
40
+ ```py
41
+ import fxn
42
+
43
+ prediction = fxn.Prediction.create(
44
+ tag="@samplefxn/stable-diffusion",
45
+ prompt="An astronaut riding a horse on Mars"
46
+ )
47
+ image = prediction.results[0]
48
+ image.show()
43
49
  ```
44
50
 
45
- You should see information about your Function account:
46
-
47
- ![login to CLI](https://raw.githubusercontent.com/fxnai/.github/main/auth_login.gif)
48
-
49
- ## Making a Prediction
50
- You can start off by running an existing predictor [on Function](https://fxn.ai/explore). Let's run the [`@natml/stable-diffusion`](https://fxn.ai/@natml/stable-diffusion) predictor which accepts a text `prompt` and generates a corresponding image. In terminal, run the following command:
51
+ ### In the CLI
52
+ Open up a terminal and run the following command:
51
53
 
52
54
  ```sh
53
- fxn predict @natml/stable-diffusion --prompt "An astronaut riding a horse on the moon"
55
+ fxn predict @samplefxn/stable-diffusion --prompt "An astronaut riding a horse on the moon"
54
56
  ```
55
57
 
56
- And within a few seconds, you should see a creepy-looking image pop up 😅:
58
+ Within a few seconds, you should see a creepy-looking image pop up 😅:
57
59
 
58
60
  ![prediction](https://raw.githubusercontent.com/fxnai/.github/main/predict.gif)
59
61
 
@@ -7,33 +7,35 @@ Run AI prediction functions (a.k.a "predictors") in your Python apps. With Funct
7
7
  ## Installing Function
8
8
  Function is distributed on PyPi. This distribution contains both the Python client and the command line interface (CLI). To install, open a terminal and run the following command:
9
9
  ```sh
10
- pip install fxn
10
+ pip install --upgrade fxn
11
11
  ```
12
12
 
13
13
  > Note that Function requires Python 3.9+
14
14
 
15
- ## Signing in to Function
16
- Head over to [fxn.ai](https://fxn.ai) to create an account by logging in. Once you do, generate an access key:
17
-
18
- ![generate access key](https://raw.githubusercontent.com/fxnai/.github/main/access_key.gif)
19
-
20
- Now, let's login to the Function CLI with your access key. Open a terminal and run the following command:
21
- ```sh
22
- fxn auth login <ACCESS KEY>
15
+ ## Making a Prediction
16
+ Let's run the [`@samplefxn/stable-diffusion`](https://fxn.ai/@samplefxn/stable-diffusion) predictor which accepts a text `prompt` and generates a corresponding image.
17
+
18
+ ### In Python
19
+ Run the following Python script:
20
+ ```py
21
+ import fxn
22
+
23
+ prediction = fxn.Prediction.create(
24
+ tag="@samplefxn/stable-diffusion",
25
+ prompt="An astronaut riding a horse on Mars"
26
+ )
27
+ image = prediction.results[0]
28
+ image.show()
23
29
  ```
24
30
 
25
- You should see information about your Function account:
26
-
27
- ![login to CLI](https://raw.githubusercontent.com/fxnai/.github/main/auth_login.gif)
28
-
29
- ## Making a Prediction
30
- You can start off by running an existing predictor [on Function](https://fxn.ai/explore). Let's run the [`@natml/stable-diffusion`](https://fxn.ai/@natml/stable-diffusion) predictor which accepts a text `prompt` and generates a corresponding image. In terminal, run the following command:
31
+ ### In the CLI
32
+ Open up a terminal and run the following command:
31
33
 
32
34
  ```sh
33
- fxn predict @natml/stable-diffusion --prompt "An astronaut riding a horse on the moon"
35
+ fxn predict @samplefxn/stable-diffusion --prompt "An astronaut riding a horse on the moon"
34
36
  ```
35
37
 
36
- And within a few seconds, you should see a creepy-looking image pop up 😅:
38
+ Within a few seconds, you should see a creepy-looking image pop up 😅:
37
39
 
38
40
  ![prediction](https://raw.githubusercontent.com/fxnai/.github/main/predict.gif)
39
41
 
@@ -9,7 +9,7 @@ from enum import Enum
9
9
  from pathlib import Path
10
10
  from typing import Dict, List, Optional, Tuple, Union
11
11
 
12
- from .api import query
12
+ from .api import query as queryfxn
13
13
  from .dtype import Dtype
14
14
  from .profile import Profile
15
15
  from .storage import Storage, UploadType
@@ -111,7 +111,7 @@ class Predictor:
111
111
  Predictor: Predictor.
112
112
  """
113
113
  # Query
114
- response = query(f"""
114
+ response = queryfxn(f"""
115
115
  query ($input: PredictorInput!) {{
116
116
  predictor (input: $input) {{
117
117
  {cls.FIELDS}
@@ -150,7 +150,7 @@ class Predictor:
150
150
  list: User predictors.
151
151
  """
152
152
  # Query
153
- response = query(f"""
153
+ response = queryfxn(f"""
154
154
  query ($user: UserInput, $predictors: UserPredictorsInput) {{
155
155
  user (input: $user) {{
156
156
  predictors (input: $predictors) {{
@@ -187,7 +187,7 @@ class Predictor:
187
187
  Search predictors.
188
188
 
189
189
  Parameters:
190
- query (str): Search query.
190
+ q (str): Search query.
191
191
  offset (int): Pagination offset.
192
192
  count (int): Pagination count.
193
193
  access_key (str): Function access key.
@@ -196,7 +196,7 @@ class Predictor:
196
196
  list: Relevant predictors.
197
197
  """
198
198
  # Query
199
- response = query(f"""
199
+ response = queryfxn(f"""
200
200
  query ($input: PredictorsInput!) {{
201
201
  predictors (input: $input) {{
202
202
  {cls.FIELDS}
@@ -251,7 +251,7 @@ class Predictor:
251
251
  notebook = Storage.upload(notebook, UploadType.Notebook) if isinstance(notebook, Path) else notebook
252
252
  media = Storage.upload(media, UploadType.Media) if isinstance(media, Path) else media
253
253
  # Query
254
- response = query(f"""
254
+ response = queryfxn(f"""
255
255
  mutation ($input: CreatePredictorInput!) {{
256
256
  createPredictor (input: $input) {{
257
257
  {cls.FIELDS}
@@ -297,7 +297,7 @@ class Predictor:
297
297
  bool: Whether the predictor was successfully deleted.
298
298
  """
299
299
  # Query
300
- response = query(f"""
300
+ response = queryfxn(f"""
301
301
  mutation ($input: DeletePredictorInput!) {{
302
302
  deletePredictor (input: $input)
303
303
  }}
@@ -326,7 +326,7 @@ class Predictor:
326
326
  Predictor: Archived predictor.
327
327
  """
328
328
  # Query
329
- response = query(f"""
329
+ response = queryfxn(f"""
330
330
  mutation ($input: ArchivePredictorInput!) {{
331
331
  archivePredictor (input: $input) {{
332
332
  {cls.FIELDS}
@@ -9,6 +9,7 @@ from numpy import ndarray
9
9
  from pathlib import Path, PurePath
10
10
  from PIL import Image
11
11
  from rich import print_json
12
+ from rich.progress import Progress, SpinnerColumn, TextColumn
12
13
  from tempfile import mkstemp
13
14
  from typer import Argument, Context, Option
14
15
 
@@ -21,14 +22,20 @@ def predict (
21
22
  context: Context = 0
22
23
  ):
23
24
  # Predict
24
- inputs = { context.args[i].replace("-", ""): _parse_value(context.args[i+1]) for i in range(0, len(context.args), 2) }
25
- prediction = Prediction.create(
26
- tag=tag,
27
- **inputs,
28
- raw_outputs=raw_outputs,
29
- return_binary_path=True,
30
- access_key=get_access_key()
31
- )
25
+ with Progress(
26
+ SpinnerColumn(spinner_name="point"),
27
+ TextColumn("[progress.description]{task.description}"),
28
+ transient=True
29
+ ) as progress:
30
+ progress.add_task(description="Making prediction...", total=None)
31
+ inputs = { context.args[i].replace("-", ""): _parse_value(context.args[i+1]) for i in range(0, len(context.args), 2) }
32
+ prediction = Prediction.create(
33
+ tag=tag,
34
+ **inputs,
35
+ raw_outputs=raw_outputs,
36
+ return_binary_path=True,
37
+ access_key=get_access_key()
38
+ )
32
39
  # Parse results
33
40
  images = []
34
41
  if hasattr(prediction, "results") and prediction.results is not None:
@@ -3,4 +3,4 @@
3
3
  # Copyright © 2023 NatML Inc. All Rights Reserved.
4
4
  #
5
5
 
6
- __version__ = "0.0.14"
6
+ __version__ = "0.0.16"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fxn
3
- Version: 0.0.14
3
+ Version: 0.0.16
4
4
  Summary: Run on-device and cloud AI prediction functions in Python. Register at https://fxn.ai.
5
5
  Home-page: https://fxn.ai
6
6
  Author: NatML Inc.
@@ -27,33 +27,35 @@ Run AI prediction functions (a.k.a "predictors") in your Python apps. With Funct
27
27
  ## Installing Function
28
28
  Function is distributed on PyPi. This distribution contains both the Python client and the command line interface (CLI). To install, open a terminal and run the following command:
29
29
  ```sh
30
- pip install fxn
30
+ pip install --upgrade fxn
31
31
  ```
32
32
 
33
33
  > Note that Function requires Python 3.9+
34
34
 
35
- ## Signing in to Function
36
- Head over to [fxn.ai](https://fxn.ai) to create an account by logging in. Once you do, generate an access key:
37
-
38
- ![generate access key](https://raw.githubusercontent.com/fxnai/.github/main/access_key.gif)
39
-
40
- Now, let's login to the Function CLI with your access key. Open a terminal and run the following command:
41
- ```sh
42
- fxn auth login <ACCESS KEY>
35
+ ## Making a Prediction
36
+ Let's run the [`@samplefxn/stable-diffusion`](https://fxn.ai/@samplefxn/stable-diffusion) predictor which accepts a text `prompt` and generates a corresponding image.
37
+
38
+ ### In Python
39
+ Run the following Python script:
40
+ ```py
41
+ import fxn
42
+
43
+ prediction = fxn.Prediction.create(
44
+ tag="@samplefxn/stable-diffusion",
45
+ prompt="An astronaut riding a horse on Mars"
46
+ )
47
+ image = prediction.results[0]
48
+ image.show()
43
49
  ```
44
50
 
45
- You should see information about your Function account:
46
-
47
- ![login to CLI](https://raw.githubusercontent.com/fxnai/.github/main/auth_login.gif)
48
-
49
- ## Making a Prediction
50
- You can start off by running an existing predictor [on Function](https://fxn.ai/explore). Let's run the [`@natml/stable-diffusion`](https://fxn.ai/@natml/stable-diffusion) predictor which accepts a text `prompt` and generates a corresponding image. In terminal, run the following command:
51
+ ### In the CLI
52
+ Open up a terminal and run the following command:
51
53
 
52
54
  ```sh
53
- fxn predict @natml/stable-diffusion --prompt "An astronaut riding a horse on the moon"
55
+ fxn predict @samplefxn/stable-diffusion --prompt "An astronaut riding a horse on the moon"
54
56
  ```
55
57
 
56
- And within a few seconds, you should see a creepy-looking image pop up 😅:
58
+ Within a few seconds, you should see a creepy-looking image pop up 😅:
57
59
 
58
60
  ![prediction](https://raw.githubusercontent.com/fxnai/.github/main/predict.gif)
59
61
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes