Building CLI with Google's Fire Python Package - Introduction

Building Command Line Tools with Python, Julia and Nodejs Module 02 - Building Command Line Tools in Python with Google's Fire
13 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€67.35
List Price:  €96.21
You save:  €28.86
£55.83
List Price:  £79.77
You save:  £23.93
CA$100.76
List Price:  CA$143.95
You save:  CA$43.19
A$112.23
List Price:  A$160.33
You save:  A$48.10
S$95.14
List Price:  S$135.93
You save:  S$40.78
HK$543.62
List Price:  HK$776.63
You save:  HK$233.01
CHF 63.04
List Price:  CHF 90.06
You save:  CHF 27.02
NOK kr797.48
List Price:  NOK kr1,139.30
You save:  NOK kr341.82
DKK kr502.49
List Price:  DKK kr717.87
You save:  DKK kr215.38
NZ$124.10
List Price:  NZ$177.29
You save:  NZ$53.19
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.18
৳8,361.55
List Price:  ৳11,945.58
You save:  ৳3,584.03
₹5,962.79
List Price:  ₹8,518.63
You save:  ₹2,555.84
RM314.04
List Price:  RM448.65
You save:  RM134.61
₦108,335.42
List Price:  ₦154,771.52
You save:  ₦46,436.10
₨19,495.71
List Price:  ₨27,852.21
You save:  ₨8,356.49
฿2,390.81
List Price:  ฿3,415.60
You save:  ฿1,024.78
₺2,467.44
List Price:  ₺3,525.07
You save:  ₺1,057.62
B$434.14
List Price:  B$620.23
You save:  B$186.09
R1,296.68
List Price:  R1,852.48
You save:  R555.80
Лв131.68
List Price:  Лв188.12
You save:  Лв56.44
₩102,198.93
List Price:  ₩146,004.73
You save:  ₩43,805.79
₪256.56
List Price:  ₪366.53
You save:  ₪109.97
₱4,090.81
List Price:  ₱5,844.26
You save:  ₱1,753.45
¥10,994.99
List Price:  ¥15,707.80
You save:  ¥4,712.81
MX$1,408.98
List Price:  MX$2,012.91
You save:  MX$603.93
QR255.09
List Price:  QR364.43
You save:  QR109.34
P967.82
List Price:  P1,382.66
You save:  P414.84
KSh9,046.20
List Price:  KSh12,923.70
You save:  KSh3,877.50
E£3,562.49
List Price:  E£5,089.49
You save:  E£1,527
ብር8,907.19
List Price:  ብር12,725.10
You save:  ብር3,817.91
Kz63,830.88
List Price:  Kz91,190.88
You save:  Kz27,360
CLP$69,323.69
List Price:  CLP$99,038.09
You save:  CLP$29,714.40
CN¥510.80
List Price:  CN¥729.75
You save:  CN¥218.94
RD$4,245.36
List Price:  RD$6,065.06
You save:  RD$1,819.70
DA9,465.07
List Price:  DA13,522.10
You save:  DA4,057.03
FJ$162.39
List Price:  FJ$232
You save:  FJ$69.60
Q539.11
List Price:  Q770.19
You save:  Q231.08
GY$14,638.77
List Price:  GY$20,913.42
You save:  GY$6,274.65
ISK kr9,772.70
List Price:  ISK kr13,961.60
You save:  ISK kr4,188.90
DH703.98
List Price:  DH1,005.73
You save:  DH301.75
L1,291.33
List Price:  L1,844.84
You save:  L553.50
ден4,143.97
List Price:  ден5,920.21
You save:  ден1,776.24
MOP$559.97
List Price:  MOP$800
You save:  MOP$240.02
N$1,289.45
List Price:  N$1,842.15
You save:  N$552.70
C$2,574.80
List Price:  C$3,678.44
You save:  C$1,103.64
रु9,534.71
List Price:  रु13,621.60
You save:  रु4,086.89
S/260.99
List Price:  S/372.86
You save:  S/111.86
K283.85
List Price:  K405.52
You save:  K121.66
SAR262.91
List Price:  SAR375.60
You save:  SAR112.69
ZK1,936.45
List Price:  ZK2,766.47
You save:  ZK830.02
L335.12
List Price:  L478.77
You save:  L143.64
Kč1,694.03
List Price:  Kč2,420.15
You save:  Kč726.12
Ft27,771.44
List Price:  Ft39,675.18
You save:  Ft11,903.74
SEK kr774.38
List Price:  SEK kr1,106.30
You save:  SEK kr331.92
ARS$71,792.58
List Price:  ARS$102,565.23
You save:  ARS$30,772.64
Bs484.55
List Price:  Bs692.24
You save:  Bs207.69
COP$307,165.41
List Price:  COP$438,826.54
You save:  COP$131,661.12
₡35,530.54
List Price:  ₡50,760.09
You save:  ₡15,229.55
L1,777.33
List Price:  L2,539.15
You save:  L761.82
₲546,250
List Price:  ₲780,390.60
You save:  ₲234,140.59
$U3,115.91
List Price:  $U4,451.49
You save:  $U1,335.58
zł287.82
List Price:  zł411.19
You save:  zł123.37
Already have an account? Log In

Transcript

All right, so welcome back. Again, my name is Jessie. And in this session of the course, we try to see how to work with a very nice filmic library called fire to fire two by Google that allows you to automatically generate your life from any point, Python function, object or class. So let's see how to work with it. So first of all, to install it, just go with pip install file, or copy this one, and then I'll paste it here we are using Python three, which is good PIP three, then you'll be able to install it if it is very interesting. So it's easy to open of exposing your full component using this special option to fire fire class or you can also put a specific specific or particular function right.

So using a special option in which you pass in your function inside your class, they can to expose an entire class itself as well as variables. Then you can also expose a sink additionally of value of functions or values of any other stock disposal option of key value pair. So these are the various With you can actually export or convert your simple function object or class into a simple sealer. So in musi ally, when you're running hope you just go with this option without the dough justice. But in fact, to run help, you have to go with this option, right? It is an interactive option.

This is the trees that allow us to be able to check for trees step by step process to execute a particular function. So let's see what we did. So I've already started so let's move on to the way. And then let's create our sample file. It's going to create a sample file here called basic CRI, right? It's actually I've been doing, I'm going to be storing it inside our main file here.

To see space is going to be basic clr.pi. Very interesting. Now let's go to a credit. Listen, I've created a function called greet. That takes a name and then it prints out something like let's say hello Then, today Neela depends on us to run this particular function, how to fit a four quarter budget screen in our passing the name here, so let's say Tita Daniel, it, so I save it in the night he don't want to execute, it has to come back to my terminal, I'm using Windows 10. Now that I just go with my Python three, then I run it as basic CLR.

And it's going to execute it. I looked at it. Very, very interesting, because I want to change it up to keep on changing the name from Peter Daniel to Peter, Paul. And then if I run it again, it's going to bring it to picked up. So this is good, but it's not the best. So I want to commit a simple function into a CLA that I'll just have to pass in the name.

Daniel Dennett automatically gives me the result, right to make it reusable. So how do you do that to FFI gives you the option of doing that in a simple way. So let's see how to do that. We're just going to come back to this place to be for an input file. That is what I You need, then you take off this particular option, then you create an F made function, then you bring your fire, but fire classic. So this class is going to expose everything.

So it's going to expose everything, everything. Suppose every component that whether this class, whether it's a function or a bomb, so let's save it now. And let's come back again, without us and I hope it's going to give us instructions on how to use this selector. So this is going to be the name. So the name is going to be the name of the file, the synopsis, how to use it, so it's going to divide it into groups, which is a fact that itself right here, as you can see, or into commands, the commands are usually going to be the functions just trying to expose. So we have our grid function.

So to run this one, I have to come back again and go into grid. Then Peter, right. It's better not going to run it if it was Hello, PETA. Very, very simple, right? So with this option, it is good to expose everything that is a budget and To run it, you just call the function, they would have called a function from here, right with a grid, then you pass into the grid, and you pass in the name use. So this is giving you the option of doing this without actually writing that particular function by calling the function from the terminology, very interested in a very simple, right.

Very nice. Now, we can also export every component. So it's not only just functions, but in case I pass in a variable, so let's call it age, then I pass in the age of 24, for PETA, and I save it and I come back again. So this one to help is going to show me not only just the greet function, but also the age verb to start weakness group comma m value, right. Today group is a fire main class, the command is the function that we have here, right? And then you also have the value which is he right?

Very, very interested in real cool. So that is one of the ways of doing it. So without supplying it, it's going to give us the But to get the hook and just go with the justice, Justice help, it must be true, right? So it must be choose to allow to work around it. Now it's going to give us a CMT. Now we have added to be very interesting, very simple.

That is how to expose everything, and also expose class, let's create a simple class. That's good as employer. And now I can actually come back here, close this. And let's try it again. With the help, it's going to expose the class object also very interested to see we have our grid, we have our employee, right, very nice. So this option exposes every component, right?

Whether it is a function or a class. So let's see how to expose only a function to this puzzle a function is going to fire. So let me comment this one out. Let's create another one. So let's just also fire then to a spoon with a function. We have only the grid today.

So this is supposedly the grid Good, we're only going to explore the good and ignore the rest, right? So if I save it, do we have our employee class here, our ADA, only the greet will be exposed. So let's click off this and then let's run it again. That's only going to suppose holiday greets right to holiday great. It's been a spoof and it's picking up this particular brand name. So, it gets out you run it now, I can run it by this option by since you see that the center of the visit usually just how to use it.

So I just go with the ally, then Danny is referring to this particular name is Alisha Gute is been exposed by passing the name Jessie Hello Jessie very, very interested is how to expose a single function right? With this option is this exposes a single function right? That is how to expose a single function. So it gives you two we want to expose the class. Yes, do the same Then copy this one here. Then let's come back to this place and then pass in the class employee.

That's going to expose all the employee. So I can just see expose a single class. This one was needed to split a class or description. So let's come back here. And then let's run it again. To see that we have our basic position after the name and then we forgot listing of this to that at least we see one, then let's initialize it, right.

This one again, pivoted, and now it's giving us the employee as the only thing that we have right? As well as the x. So it gives these x a name. So let's say this one was named, making it quite nicer. To claim it's going to show that one maybe that's the x here, right? Just as we have x is equal to x.

Now see that not as his name, right so to to use it just go with the basic see Li then the name right to be able to exclude so let's print something from it. You can just make it like this for Deaf then presentation as you always do itself well let's go it's a print, print and we are printing employee brackets. format. Now Patsy my so totally saved this one and I come back here. See this play of this. Run it again.

Good to see that now that name is going to be specific Right, pivot, right. So for me to run it out, just run it in this particular option. So I just go with this Python, then I run it with the name, printed the name of the employer. And I specify the name as usual, it's going to print it perfectly for us retain it equals retention. So this is employee name, to show a premium to show plain English, that is how to work with it. Right?

Very, very interesting, very simple. So that is how to expose not just only the entire component, but a single function in a class. So let's see the next one of exposing multiple functions, who to expose multiple functions are going to be this option to fire that. Fire. Now passing the classes or the functions that own to expose the listing of this one, this command all of these and out. Let's create another function here.

Call it a C bye Passing the name doing the same thing day two or copy the sentence was only the same function I created, which is going to be this function and then we call it us Goodbye Goodbye right pivot. So, to expose these two functions are just without this right without passing it here, as we learnt is going to expose every function every component is also going to expose them together. can actually use it to get data to show move they see in a grid as the commands to greet see to so to run it is have to come back to the same thing here as greet. didn't pass in the name. There's going to write Hello, Peter, to work with the sea. Say bye.

Right? Goodbye PETA. So this option, and then this is going to expose everything as related. To specify these particular functions, you can just come back He said our function here, and then give it like we did here. So the simplest way is just create additional, right. So it's going to be, if I have this, you got to take the grid, as in, that's what you use, then grid, the grid function, right, then I can just come back again and see by so let's put it together like this.

And then you go with C by function. So this so this is how we are going to be calling it right. So we'll be calling it with this one. If I save it now, in the list, come back again. Close and then Randy hope to see how it works. For now you're going to have to greet and then they say bye.

So we have a greet see by right because as you can see you have our greet. Now see by so to qualify, you have to just go with this then greet suspended grades, then I can put it Yes. For the grades for the query to see by just go with C. Notice that there is no dash D, unlike the function that we have here, which has the dash right, because we are using this key value pay to export them, basically ran it again and see Hello, or goodbye. Or the basic idea about how to convert your functions your objects, your classes into a CLR using fire. So, the basic idea this input player, right your normal function, then you just expose it, expose everything with this option or expose a particular single function with this option. expose a class with this option or expose several functions, multiple functions with this custom bunches.

So I can actually make this one custom by going with I make this one ad right Let's see. Hi. Now if I come back into town to run it, it's going to be the high school. Let's go with to help me see that now is Heidi switch through it, I have to close this and then now run it again. They see to vote very well Hi. So I have to run it as Hi, Jane.

Right. Good to bring the Hello Jane. So that is very, very interesting. So we can you decide to customize the particular function or to call it how you wanted to call it. So thank you for watching and see you next session. Stay blessed

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.