timelink.app.backend package
Submodules
timelink.app.backend.settings module
- class timelink.app.backend.settings.Settings(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None, _cli_shortcuts: Mapping[str, str | list[str]] | None = None, _secrets_dir: PathType | None = None, *, timelink_app_name: str = 'Timelink', timelink_admin_email: str = 'joaquim@uc.pt', timelink_users_db_type: str = 'sqlite', timelink_users_db_name: str = 'timelink_users.sqlite', timelink_app_url: str = 'http://localhost:8008', timelink_users_db_path: str = '', timelink_admin_pwd: str = 'adminpwd', timelink_project_db_type: str = 'sqlite')[source]
Timelink settings.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[SettingsConfigDict] = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'cli_avoid_json': False, 'cli_enforce_required': False, 'cli_exit_on_error': True, 'cli_flag_prefix_char': '-', 'cli_hide_none_type': False, 'cli_ignore_unknown_args': False, 'cli_implicit_flags': False, 'cli_kebab_case': False, 'cli_parse_args': None, 'cli_parse_none_str': None, 'cli_prefix': '', 'cli_prog_name': None, 'cli_shortcuts': None, 'cli_use_class_docs_for_groups': False, 'enable_decoding': True, 'env_file': None, 'env_file_encoding': None, 'env_ignore_empty': False, 'env_nested_delimiter': None, 'env_nested_max_split': None, 'env_parse_enums': None, 'env_parse_none_str': None, 'env_prefix': '', 'extra': 'forbid', 'json_file': None, 'json_file_encoding': None, 'nested_model_default_partial_update': False, 'protected_namespaces': ('model_validate', 'model_dump', 'settings_customise_sources'), 'secrets_dir': None, 'toml_file': None, 'validate_default': True, 'yaml_config_section': None, 'yaml_file': None, 'yaml_file_encoding': None}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
timelink.app.backend.timelink_webapp module
Main class for the Timelink web application.
- class timelink.app.backend.timelink_webapp.TimelinkWebApp(app_name: str = 'timelink', timelink_url: str = 'http://localhost:8008', timelink_home: str | None = None, kleio_server: KleioServer | None = None, users_db_type: str = 'sqlite', users_db_name: str = 'timelink_users.sqlite', kleio_image=None, kleio_version=None, kleio_token=None, kleio_update=False, postgres_image=None, postgres_version=None, sqlite_dir=None, stop_duplicates=True, initial_users: list[User] | None = None, **connection_args)[source]
A class to interact with the Timelink system from a FastAPI web application
It stores TimelinkDatabase, KleioServer objects and Fief (user management) objects.
- app_name
Name of the application.
- Type:
str
- timelink_home
Directory where the Timelink database is located.
- Type:
str
- host_url
URL of the Timelink web application.
- Type:
str
- kleio_server
A KleioServer instance.
- Type:
KleioServer
- users_db_type
Type of the users database (sqlite or postgres).
- Type:
str
- users_db_name
Name of the users database.
- Type:
str
- users_db
A UserDatabase instance.
- Type:
UserDatabase
- auth_manager
URL of the authentication manager.
- Type:
str
- app_manager
URL of the application manager.
- Type:
str
- kleio_image
Name of the Kleio image to use.
- Type:
str
- postgres_image
Name of the postgres image to use.
- Type:
str
- postgres_version
Version of the postgres image to use.
- Type:
str
- sqlite_dir
Directory where the sqlite databases are located.
- Type:
str
- stop_duplicates
If True, stop other kleio servers for the same timelink home.
- Type:
bool
Create a TimelinkWebApp instance
Setup of Kleio Server and Timelink database is done here.
Several functions are provided to manage the kleio files and access the database.
- Parameters:
app_name – name of the application
timelink_url – URL of the Timelink web application
timelink_home – directory where the Timelink database is located
kleio_server – a KleioServer instance
users_db_type – type of the users database (sqlite or postgres)
users_db_name – name of the users database
kleio_image – name of the Kleio image to use
kleio_version – version of the Kleio image to use
kleio_token – token to access the Kleio server
kleio_update – if True, update the Kleio server
postgres_image – name of the postgres image to use
postgres_version – version of the postgres image to use
sqlite_dir – directory where the sqlite databases are located
initial_users – list of initial users (deprecated)
stop_duplicates – if True, stop duplicates
**connection_args – extra arguments to pass to the TimelinkDatabase
- Returns:
A TimelinkWebApp instance
- get_file_paths(file_spec, rows, column)[source]
Get the file paths from DataFrame of from a string
TODO: #27 add parameter to convert the paths to absolute local paths
- get_import_rpt(file_spec: DataFrame | str, rows=None, match_path=False, **kwargs)[source]
Show the import report for a given file specification
- Parameters:
file_spec – file specification (DataFrame or string) If a DataFrame, it should have the columns ‘path’ and the arguments ‘rows’ must be present
rows – if file_spec is a DataFrane, the row number to show
match_path – if True, the path is used to retrieve the import report; if false the filename is used (default).
**kwargs – extra arguments to pass to the show_import_rpt method in the TimelinkDatabase class
- get_import_status(data_frame=True, **kwargs)[source]
Get the import status of Kleio Files
- Returns:
A dictionary with the status of the import process
- get_imported_files(data_frame=True, **kwargs)[source]
Get the list of imported files in the database
See the get_imported_files method in the TimelinkDatabase class:
timelink.api.database.TimelinkDatabase.get_imported_files()- Parameters:
data_frame – if True, return a pandas DataFrame; otherwise, return a list of dictionaries
**kwargs – extra arguments to pass to the get_imported_files method
- get_info(show_token=False, show_password=False)[source]
Print information about the Timelink Webapp object
- get_kleio_files(data_frame=True, **kwargs)[source]
Get the list of files in the kleio server.
Alias to
timelink.notebooks.TimelinkNotebook.get_import_status()but returns a subset of the columns.# Column Non-Null Count Dtype — —— ————– —– 0 path 3 non-null object 1 name 3 non-null object 2 size 3 non-null int64 3 directory 3 non-null object 4 modified 3 non-null datetime64[ns, UTC] 5 modified_iso 3 non-null datetime64[ns, UTC] 6 modified_string 3 non-null object 7 qtime 3 non-null datetime64[ns, UTC] 8 qtime_string 3 non-null object 9 source_url 3 non-null object 10 status 3 non-null object 11 translated 3 non-null datetime64[ns, UTC] 12 translated_string 3 non-null object 13 errors 3 non-null int64 14 warnings 3 non-null int64 15 version 3 non-null object 16 rpt_url 3 non-null object 17 xml_url 3 non-null object 18 import_status 3 non-null object 19 import_errors 3 non-null Int64 20 import_warnings 3 non-null Int64 21 import_error_rpt 3 non-null object 22 import_warning_rpt 3 non-null object 23 imported 3 non-null int64 24 imported_string 3 non-null int64
- get_postgres_databases()[source]
Get the list of postgres databases
- Returns:
A list of postgres databases
- get_project_dirs()[source]
Get the list of projects
Projects are sub directories of the timelink home directory / projects directory.
- get_sqlite_databases(sqlite_dir=None, **kwargs)[source]
Get the list of sqlite databases
- Parameters:
sqlite_dir – directory where the sqlite databases are located
**kwargs – extra arguments to pass to the get_sqlite_databases function
- Returns:
A list of sqlite databases
- get_translation_report(file_spec, rows=None)[source]
Show the translation report for a given file specification
- Parameters:
file_spec – file specification (DataFrame or string) If a DataFrame, it should have the columns ‘rpt_url’ and the arguments ‘rows’ must be present
rows – if file_spec is a DataFrane, the row number of interest