Code Monkey home page Code Monkey logo

nt_tool's Introduction

User Guide

update Jun 1 2023

See update. Update.md

Run project in Docker

1.Install docker desktop

2.1 Create a docker-compose.yml file (preferably in a new work directory)

version: "3.8"
services:
  web:
    image: falantasw/nt-tool:${FILL ME WITH LATEST TAG}
    pull_policy: if_not_present
    ports:
      - 8050:8050
    volumes:
      - ./input:/code/input
      - ./output:/code/output

Visit falanta's docker hub registry and update the image above with the latest tag.

Sample compose file

version: "3.8"
services:
  web:
    image: falantasw/nt-tool:0.0.1
    pull_policy: if_not_present
    ports:
      - 8050:8050
    volumes:
      - ./input:/code/input
      - ./output:/code/output

2.2. Create an input directory and an output directory under the directory where the docker-compose.yml stays.

2.3. Use the input json as templates to create some input json files in the input directory you just created.

3.If you are using linux or mac, open a terminal. If you are using windows, open a command prompt or PowerShell window. Navigate to the directory where you created the docker compose yaml file. Run the compose up command

docker-compose up

Note: make sure your docker desktop is running

4.1 If you would like to use the web UI search, open a browser and go to

http://127.0.0.1:8050

4.2 If you would like to generate a excel output, you may use the following docker command

docker exec -i $(docker container ls --filter "ancestor=falantasw/nt-tool:0.0.1" --format "{{.ID}}" | head -n 1 | xargs) python /code/src/main.py ${FILL ME WITH AN AIRLINE} --input_file /code/input/${${FILL ME WITH YOU INPUT FILE NAME}} --output_dir /code/output/

Eligible airline functions

use_aa
use_dl
use_ac

A sample docker command looks like

docker exec -i $(docker container ls --filter "ancestor=tool:latest" --format "{{.ID}}" | head -n 1 | xargs) python /code/src/main.py use_aa --input_file /code/input/aa_or_dl_input.json --output_dir /code/output/

Run project in local

  1. install requirements
pip install -r requirements.txt
  1. In use_aa.py or use_ac.py or use_dl.py set the conditions you want.
    origins = ['HKG']
    destinations = ['KUL']
    start_dt = '2023-03-31'
    end_dt = '2023-03-31'
    dates = date_range(start_dt, end_dt)
    #  means eco, pre, biz and first
    cabin_class = [
        "ECO",
        "PRE",
        "BIZ",
        "FIRST"
    ]
    airbound_filter = AirBoundFilter(
        max_stops=1,
        airline_include=[],
        airline_exclude=['MH'],
    )
    price_filter = PriceFilter(
        min_quota=1,
        max_miles_per_person=999999,
        preferred_classes=[CabinClass.J, CabinClass.F, CabinClass.Y],
        mixed_cabin_accepted=True
    )
  1. Run use_aa.py or use_ac.py and you will see the output file.

  2. You can also run web_branch.py and go through with a web view. Currently the app wiil use both engines to search results.

If you like this project, welcome to buy me a coffee.

Buy Me A Coffee

nt_tool's People

Contributors

chenxiujin10 avatar kqfu avatar mileshuang32 avatar mrseaman avatar singletc avatar xmsley614 avatar yshenfab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nt_tool's Issues

403

It doesn't work.

Running locally returns 403

Running use_ac.py returns a correct looking response in get_aws_config, but then the response in get_market_token returns 403 status code. Any ideas how to fix it?

ac search is broken?

tried to use use_ac.py on LAX - LHR for the next year. No results are returned, which should be highly unlikely. Any changes in the ac_searcher class?

python3.8 error

v1 = v1 | segs_single | prices_single

TypeError: unsupported operand type(s) for |: 'dict' and 'dict'

File name 'parser.py' can create problems

When I was trying to run the main.py, it raises a bug saying

Traceback (most recent call last): File "xxx\nt_tool\main_zh.py", line 3, in <module> from parser import convert_response, results_to_excel ImportError: cannot import name 'convert_response' from 'parser' (unknown location)

https://stackoverflow.com/questions/58585690/python-cannot-import-unknown-location

it seems "parser" is a library in python. I renamed the "parser" to "parserNT" and then the problem was solved.

Maybe it is a good idea to change the name 'parser' to something like 'utils'?

index out of range in convert_aa_response_to_models

use_aa.py
search for HKG to DXB on 2023-05-20 @ 14:56:56
error
Traceback (most recent call last):
File "D:\python\nt_tool\use_aa.py", line 37, in
v1 = convert_aa_response_to_models(response)
File "D:\python\nt_tool\nt_parser.py", line 262, in convert_aa_response_to_models
is_mix, mix_detail = calculate_aa_mix_by_segment(CabinClass(temp_pricing.cabin_class), duration_list,
File "D:\python\nt_tool\nt_parser.py", line 75, in calculate_aa_mix_by_segment
mix_detail = '+'.join(str(round(percentage_list[x] * 100, 0)) + '%' + actual_cabin_list[x]
File "D:\python\nt_tool\nt_parser.py", line 75, in
mix_detail = '+'.join(str(round(percentage_list[x] * 100, 0)) + '%' + actual_cabin_list[x]
IndexError: list index out of range

Why is pricing a list?

I see that each AirBound, the price is a List[Pricing].
Why is it a list? an airbound have many different prices?

I also found some returned result, price is empty. Why is that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.