Package: teselagen
TeselaGen Python API ClientTheTeselaGen Python API Clientruns on Python3.9+NOTE :All the following commands are supposed to be run on thebasedirectory, unless specified.Library InstallationThis library contains the TeselaGen Python API Client.To install it locally with pip:pip3installteselagenUse and loginImport theteselagenlibrary:fromteselagen.apiimportTeselaGenClientCreate an instance of the client:client=TeselaGenClient(host_url="https://<INSTANCE NAME>.teselagen.com/")Then, login by using your user email and One Time Password (OTP). You can get one fromSettings->API Passwordwithin the application. Alternatively ,you can use your application password.client.login(username="my@email.com",password="<OTP OR PASSWORD>")Once you have logged in, you don't need to do it everytime. By default login token lasts for 1 week, but you can
change the duration on creation by specifying an expiration time:client.login(username="my@email.com",password="<OTP OR PASSWORD>",expiration_time="1d")ExamplesCheck out theprovided examples. To be able
to run them:Clone or downloadteselagen/examplesOpen any notebook in theexamplesfolder with Jupyter NotebookUse the provided environmentYou can use the provided docker environment that contains a ready to use installation of all required packages to run
the notebooks. Here are the instructions according to your OSLinux/MacOSAfter clone/download, run the build script withbash build.shRun the container withbash run.shOpen your browser and set the address:http://localhost:8888. From there you can explore all example notebooksDevelopment (Linux/MacOS)Docker environmentBuild the docker environment with commandbash build.shRun the container as a developer with the commandbash run_dev.sh.
With this command theteselagenlibrary will be installed ineditablemode.DependenciesInstall dependenciesIf lock file exists (the lock file contains fixed versions of dependencies), thepoetry installcommand will install
all dependencies according to the lock file (lock filemustbe added to the repo). If the file does not exist, it
will generate the lock file again.Update dependenciesUse this command if you made changes on the dependencies at thepyproject.tomlfile:poetryupdateIt is the equivalent to make an install after deleting thelockfile.TestsAdd your credentialsTo run the tests, you must create a.credentialsfile containing the testusernameandpassword, in therootfolder.The content of.credentialsfile should look similar to the following:{"username":"ReplaceWithYourUsername","password":"ReplaceWithYourPassword"}NOTE: It should be a validJSONfile.JSON with Comments(JSONC) format is not supported.- DO NOT COMMIT THIS FILE : .credentialsModify configurationYou may modify some test configuration parameters by creating a.test_configurationfile.
This is aJSONformatted file, where you can edit the server name used for tests.
This file must be stored next to.credentialsfile. Here is an example{"host_url":"https://platform.teselagen.com"}NOTE: It should be a validJSONfile.JSON with Comments(JSONC) format is not supported.Run the testscd/home&&python3setup.pytestYou may use the docker environment for testing. For that, first build the environment withbash build.sh.
Then just run the container withbash run_dev.sh.
Once inside (docker exec -ti tgclient bash), go tohome/and you are ready to run the test command shown above.PublishingPublishing is limited to administrators. PyPi publishing is made by usingpoetry.To publish:Runpoetry buildfrom the project's root folder (same directory aspyproject.toml)Be sure you have set the credentials with the api token:poetryconfigpypi-token.pypi<TOKEN>Ask for a token to administrators if neededPublish (check you have set a new version tag inpyproject.toml):poetrypublishNotesDefault shell inUbuntuisdash, to which/bin/shis symlinked. Butdashdoesn't have thepipefailoption.
That's why some of our shell scripts have the following line:# pipefail is necessary to propagate exit codes (but it may not be supported by your shell)bash|set-opipefail>/dev/null2>&1For example, the following commands will list all options supported bysetin each of the respective shells:sh-c'set -o'dash-c'set -o'bash-c'set -o'zsh-c'set -o'So, inUbuntuit may be recommended to usebashinstead ofsh.bashsome_shell_script.shOr, as follows:.some_shell_script.sh