WEBVTT

00:00.200 --> 00:01.520
Hey there Eden here.

00:01.520 --> 00:05.240
And in this video we're going to review the repository structure.

00:05.560 --> 00:07.800
Now we're going to organize our code.

00:07.800 --> 00:09.240
So it would be readable.

00:09.560 --> 00:13.000
It will be easier to maintain and to write testing.

00:13.000 --> 00:15.200
So our application will be more robust.

00:15.400 --> 00:22.440
And while this video series was inspired by the Link Chain Team's work implementing advanced RAC solution

00:22.440 --> 00:26.800
with Landgraf and their tutorial, I had to make some refactoring.

00:26.800 --> 00:35.080
Since the tutorial was more focused on a Jupyter notebook rather than a robust software that is supposed

00:35.080 --> 00:36.280
to run in production.

00:36.800 --> 00:43.600
Now, I always like to say that our repository structure should reflect our architecture, and in our

00:43.600 --> 00:49.120
case, it's going to be our graphs architecture, the nodes and edges that will be implementing.

00:49.760 --> 00:56.480
And most of our implementation is going to be in the graph package that will create and it will have

00:56.480 --> 00:57.840
the graph py file.

00:57.840 --> 01:02.360
And that's going to be where we're going to connect all of our nodes and edges.

01:02.600 --> 01:09.600
We're going to have the state py file, which is going to have the graph state object that will be modifying

01:09.640 --> 01:11.160
during the graph execution.

01:11.480 --> 01:19.080
We also want to have a const py file for constants that we want to use in the implementation, and we

01:19.080 --> 01:22.320
want to have a subpackage called nodes.

01:22.760 --> 01:27.720
And it's going to have all of the implementation of the nodes that are going to run.

01:28.040 --> 01:33.520
So in that package is going to have a lot of files where each file is going to be a node.

01:34.240 --> 01:41.400
And we're going to have the chains package where each file in the chains package is going to be a different

01:41.400 --> 01:47.520
chain, and it should correspond to the nodes that we're creating, because each node is eventually

01:47.520 --> 01:49.720
going to run a long chain chain.

01:50.120 --> 01:53.040
Now finally, we also want to be writing tests.

01:53.040 --> 01:57.920
So I created a test package and I created a test chains file.

01:57.920 --> 02:03.360
So here we're going to be implementing our test for the chains that we're going to write.

02:03.760 --> 02:10.150
And finally we also want to write an ingestion file which is going to be holding all of the logic that

02:10.150 --> 02:15.950
will download the information we want to index, and it's going to index it in the vector store.

02:16.310 --> 02:21.870
Now, before we begin and create all of this structure, I just want to note that this is something

02:21.870 --> 02:23.070
that works for me.

02:23.110 --> 02:27.670
I'm not claiming that this is the best project structure for a graph application.

02:27.670 --> 02:32.550
I'm just saying that this is something that works well for me, for my experience, and you'll see that

02:32.550 --> 02:38.550
once we develop this application, it would be very easy to start and to improve it and to make this

02:38.550 --> 02:40.630
application more robust with tests.

02:40.670 --> 02:44.630
Or we want to make it more complex with more nodes and edges.

02:44.830 --> 02:46.630
So this is just as an FYI.

02:48.670 --> 02:49.270
All right.

02:49.270 --> 02:50.430
Let's go to the code.

02:50.470 --> 02:53.870
Now notice that the branch is two project structure.

02:53.870 --> 02:56.550
So you can find here the final code for this video.

03:00.470 --> 03:03.510
Let's go and create now a new package.

03:03.510 --> 03:06.230
And we want to call this package graph.

03:10.830 --> 03:16.750
We want now to create a new file in graph package and we'll call this file state py.

03:19.750 --> 03:21.350
This will hold our graph state.

03:22.630 --> 03:27.470
Now let's go and create another Python file and we'll call it graph.

03:27.470 --> 03:31.590
And here we're going to write all the nodes and edges and connections between them.

03:32.390 --> 03:39.030
Finally we want to create a const file for constants that we're going to be using mainly names of nodes.

03:39.510 --> 03:43.030
And under graph we want to create a new sub package.

03:43.030 --> 03:44.790
And we want to call it nodes.

03:44.950 --> 03:47.710
And it's going to have all of our nodes implementation.

03:48.590 --> 03:51.270
So each node is going to be a file in this package.

03:51.630 --> 03:55.270
And every node is eventually going to run a chain.

03:55.590 --> 03:58.510
So I want to create a new change package.

03:58.510 --> 04:04.350
And here every file is going to be a new chain that should correspond to our nodes package.

04:04.830 --> 04:08.190
And we're going to be running tests for those chains.

04:08.190 --> 04:11.350
So let's create another sub package under chains.

04:11.350 --> 04:13.230
And we want to call it tests.

04:13.950 --> 04:17.390
And I want here to add now a new file.

04:17.390 --> 04:20.070
And I'm going to call it test chains.

04:26.190 --> 04:29.590
And this is going to have all of the testing implementation.

04:30.270 --> 04:35.350
And I have to add that the naming convention here is very important because we're going to be leveraging

04:35.350 --> 04:37.910
Pytest to orchestrate and run our tests.

04:37.910 --> 04:43.350
And Pytest is going to be looking for directories, which starts with tests, and it's going to look

04:43.350 --> 04:46.870
for test files with the prefix of test.

04:47.790 --> 04:52.750
Let's now add a dummy test to this project under Test chains.

04:53.070 --> 04:57.470
So I'm going to define a new function I'm going to call it test foo.

04:58.790 --> 05:01.870
And it's going to not return anything.

05:03.070 --> 05:06.390
And here I simply want to assert that one is equal to one.

05:06.390 --> 05:07.790
So this test should pass.

05:08.190 --> 05:12.030
And now I want to test that everything is working.

05:12.030 --> 05:14.510
And Pytest is able to run the tests.

05:14.710 --> 05:20.430
I will write in the terminal pytest dot to tell Py.test to run from the current directory, which is

05:20.430 --> 05:25.590
the root directory of the project is to display from stdout.

05:26.150 --> 05:32.150
Dash V is the verbose flag, which is going to show the tests that we ran in pytest, and we can see

05:32.150 --> 05:34.830
that Pytest ran the test as we wanted.

05:34.830 --> 05:43.070
It ran test foo from the test chains file, and now let's configure our runner to run our tests through

05:43.070 --> 05:44.430
the PyCharm runner.

05:44.910 --> 05:49.190
Let's go to the top right to Edit configurations.

05:49.710 --> 05:56.390
Here we want to click the plus button and to add Python tests and to select Pytest.

05:56.670 --> 06:04.270
And here we want to give here the um the directory to be the root directory here this is the script

06:04.270 --> 06:04.710
path.

06:04.990 --> 06:09.670
And the parameters is going to be dot dash dash v like we saw earlier.

06:10.470 --> 06:18.590
And now if we'll take a look we have here test chains and we can simply um run it.

06:18.590 --> 06:19.910
So let's go and run it.

06:19.910 --> 06:26.980
And we can see we ran the test successfully and if we want, we can even see the exact execution.

06:26.980 --> 06:31.340
So this is going to be convenient when we're going to be writing and running our tests.

06:33.020 --> 06:33.580
Cool.

06:33.580 --> 06:36.540
So we're almost done with the project structure.

06:36.980 --> 06:43.340
Now we want to create another file under our root directory for our vector store ingestion.

06:44.700 --> 06:46.700
And we'll call it ingestion.

06:50.700 --> 06:53.020
And that's pretty much it.

06:53.220 --> 06:56.660
We've now created the structure for our repository.

06:56.980 --> 07:01.900
And in the next video series we're going to be implementing all of those files.

07:01.900 --> 07:05.140
And we're going to be adding more files to this structure.

07:05.700 --> 07:11.740
And if you want to compare your code or to even download it, you can go and check out the two project

07:11.740 --> 07:16.420
structure branch, where we have all of what we saw in this video there.

07:17.740 --> 07:23.420
In the next video we'll be implementing our vector store ingestion to chroma DB.
